@@ -5,7 +5,7 @@ module Reporting.Error.Syntax
55 , ParseError(..)
66 , Problem(..), Theory(..)
77 , ContextStack, Context(..)
8− , BadOp(..), Next(..), NextDecl(..)
8+ , BadOp(..), Next(..)
99 , toReport
1010 )
1111 where
@@ -91,7 +91,6 @@ data Theory
9191 | InfixOp
9292 | Digit
9393 | EndOfFile
94− | FreshLine NextDecl
9594 | BadSpace
9695 deriving (Eq, Ord)
9796
@@ -109,10 +108,6 @@ data Next
109108 deriving (Eq, Ord)
110109
111110
112−data NextDecl = ModuleDecl | DocCommentDecl | ImportDecl | OtherDecl
113− deriving (Eq, Ord)
114−
115−
116111type ContextStack = [(Context, R.Position)]
117112
118113
@@ -537,9 +532,9 @@ problemToReport subRegion problem =
537532 BadOp op stack ->
538533 case op of
539534 HasType ->
540− badOp subRegion stack "the \"has type\" operator" "(:)"
535+ badOp subRegion stack "A" "\"has type\" operator"
541536 "type annotations and record types"
542− "Maybe you want :: instead? Or maybe your indentation is a bit off?"
537+ "Maybe you want :: instead? Or maybe something is indented too much?"
543538
544539 Equals ->
545540 badEquals subRegion stack
@@ -547,7 +542,7 @@ problemToReport subRegion problem =
547542 Arrow ->
548543 if isCaseRelated stack then
549544 parseReport
550− "I ran into a stray arrow (->) while parsing this `case` expression."
545+ "I ran into a stray arrow while parsing this `case` expression."
551546 ( reflowParagraph $
552547 "All branches in a `case` must be indented the exact\
553548 \ same amount, so the patterns are vertically\
@@ -555,18 +550,18 @@ problemToReport subRegion problem =
555550 )
556551
557552 else
558− badOp subRegion stack "an arrow" "(->)"
553+ badOp subRegion stack "An" "arrow"
559554 "cases expressions and anonymous functions"
560555 "Maybe you want > or >= instead?"
561556
562557 Pipe ->
563− badOp subRegion stack "a vertical bar" "(|)"
558+ badOp subRegion stack "A" "vertical bar"
564559 "type declarations"
565560 "Maybe you want || instead?"
566561
567562 Dot ->
568563 parseReport
569− "I was not expecting a dot (.) here."
564+ "I was not expecting this dot."
570565 ( reflowParagraph $
571566 "Dots are for record access and decimal points, so\
572567 \ they cannot float around on their own. Maybe\
@@ -619,14 +614,16 @@ addPeriod msg =
619614
620615
621616badOp :: Maybe R.Region -> ContextStack -> Text -> Text -> Text -> Text -> Report.Report
622−badOp subRegion stack opName op setting hint =
623− makeParseReport subRegion ("I was not expecting " <> opName <> " here.") $
624− Help.stack
625− [ reflowParagraph $
626− "A " <> op <> " should only appear in " <> setting
627− <> contextToText "" ", but I think I am parsing " stack <> "."
628− , reflowParagraph hint
629− ]
617+badOp subRegion stack article opName setting hint =
618+ let
619+ pre =
620+ "I was not expecting this " <> opName
621+ <> contextToText "" " while parsing " stack <> "."
622+ in
623+ makeParseReport subRegion pre $
624+ reflowParagraph $
625+ article <> " " <> opName <> " should only appear in "
626+ <> setting <> ". " <> hint
630627
631628
632629badEquals :: Maybe R.Region -> ContextStack -> Report.Report
@@ -644,14 +641,14 @@ badEqualsHelp stack =
644641 case stack of
645642 [] ->
646643 reflowParagraph $
647− "Maybe you want == instead? Or maybe your indentation is a bit off?"
644+ "Maybe you want == instead? Or maybe something is indented too much?"
648645
649646 (ExprRecord, _) : _ ->
650647 reflowParagraph $
651648 "Records look like { x = 3, y = 4 } with the equals sign right\
652649 \ after the field name. Maybe you forgot a comma?"
653650
654− (Definition name, _) : rest ->
651+ (Definition _, _) : rest ->
655652 reflowParagraph $
656653 "Maybe this is supposed to be a separate definition? If so, it\
657654 \ is indented too far. "
@@ -769,14 +766,6 @@ theoryToText context theory =
769766 BadSpace ->
770767 badSpace context
771768
772− FreshLine nextDecl ->
773− "a fresh line (without any leading spaces) for " <>
774− case nextDecl of
775− ModuleDecl -> "something like `module Main exposing (..)`"
776− DocCommentDecl -> "something like `import Html exposing (text)`"
777− ImportDecl -> "an `import` or a declarations"
778− OtherDecl -> "a top-level declaration, like `view model = div [] [...]`"
779−
780769 Expecting next ->
781770 case next of
782771 Decl -> "a declaration, like `x = 5` or `type alias Model = { ... }`"