@@ -5,7 +5,7 @@ module Reporting.Error.Syntax
5 , ParseError(..)
5 , ParseError(..)
6 , Problem(..), Theory(..)
6 , Problem(..), Theory(..)
7 , ContextStack, Context(..)
7 , ContextStack, Context(..)
8− , BadOp(..), Next(..), NextDecl(..)
8+ , BadOp(..), Next(..)
@@ -91,7 +91,6 @@ data Theory
93 | EndOfFile
93 | EndOfFile
95 | BadSpace
94 | BadSpace
96 deriving (Eq, Ord)
95 deriving (Eq, Ord)
@@ -109,10 +108,6 @@ data Next
109 deriving (Eq, Ord)
108 deriving (Eq, Ord)
112−data NextDecl = ModuleDecl | DocCommentDecl | ImportDecl | OtherDecl
116type ContextStack = [(Context, R.Position)]
111type ContextStack = [(Context, R.Position)]
@@ -537,9 +532,9 @@ problemToReport subRegion problem =
537 BadOp op stack ->
532 BadOp op stack ->
538 case op of
533 case op of
539 HasType ->
534 HasType ->
540− badOp subRegion stack "the \"has type\" operator" "(:)"
535+ badOp subRegion stack "A" "\"has type\" operator"
541 "type annotations and record types"
536 "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?"
544 Equals ->
539 Equals ->
545 badEquals subRegion stack
540 badEquals subRegion stack
@@ -547,7 +542,7 @@ problemToReport subRegion problem =
548 if isCaseRelated stack then
543 if isCaseRelated stack then
549 parseReport
544 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."
551 ( reflowParagraph $
546 ( reflowParagraph $
552 "All branches in a `case` must be indented the exact\
547 "All branches in a `case` must be indented the exact\
553 \ same amount, so the patterns are vertically\
548 \ same amount, so the patterns are vertically\
@@ -555,18 +550,18 @@ problemToReport subRegion problem =
558− badOp subRegion stack "an arrow" "(->)"
553+ badOp subRegion stack "An" "arrow"
559 "cases expressions and anonymous functions"
554 "cases expressions and anonymous functions"
560 "Maybe you want > or >= instead?"
555 "Maybe you want > or >= instead?"
563− badOp subRegion stack "a vertical bar" "(|)"
558+ badOp subRegion stack "A" "vertical bar"
564 "type declarations"
559 "type declarations"
565 "Maybe you want || instead?"
560 "Maybe you want || instead?"
568 parseReport
563 parseReport
569− "I was not expecting a dot (.) here."
564+ "I was not expecting this dot."
570 ( reflowParagraph $
565 ( reflowParagraph $
571 "Dots are for record access and decimal points, so\
566 "Dots are for record access and decimal points, so\
572 \ they cannot float around on their own. Maybe\
567 \ they cannot float around on their own. Maybe\
@@ -619,14 +614,16 @@ addPeriod msg =
621badOp :: Maybe R.Region -> ContextStack -> Text -> Text -> Text -> Text -> Report.Report
616badOp :: Maybe R.Region -> ContextStack -> Text -> Text -> Text -> Text -> Report.Report
622−badOp subRegion stack opName op setting hint =
617+badOp subRegion stack article opName setting hint =
623− makeParseReport subRegion ("I was not expecting " <> opName <> " here.") $
620+ "I was not expecting this " <> opName
624− Help.stack
621+ <> contextToText "" " while parsing " stack <> "."
623+ makeParseReport subRegion pre $
625− [ reflowParagraph $
624+ reflowParagraph $
626− "A " <> op <> " should only appear in " <> setting
625+ article <> " " <> opName <> " should only appear in "
627− <> contextToText "" ", but I think I am parsing " stack <> "."
626+ <> setting <> ". " <> hint
628− , reflowParagraph hint
632badEquals :: Maybe R.Region -> ContextStack -> Report.Report
629badEquals :: Maybe R.Region -> ContextStack -> Report.Report
@@ -644,14 +641,14 @@ badEqualsHelp stack =
644 case stack of
641 case stack of
646 reflowParagraph $
643 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?"
649 (ExprRecord, _) : _ ->
646 (ExprRecord, _) : _ ->
650 reflowParagraph $
647 reflowParagraph $
651 "Records look like { x = 3, y = 4 } with the equals sign right\
648 "Records look like { x = 3, y = 4 } with the equals sign right\
652 \ after the field name. Maybe you forgot a comma?"
649 \ after the field name. Maybe you forgot a comma?"
654− (Definition name, _) : rest ->
651+ (Definition _, _) : rest ->
655 reflowParagraph $
652 reflowParagraph $
656 "Maybe this is supposed to be a separate definition? If so, it\
653 "Maybe this is supposed to be a separate definition? If so, it\
657 \ is indented too far. "
654 \ is indented too far. "
@@ -769,14 +766,6 @@ theoryToText context theory =
769 BadSpace ->
766 BadSpace ->
770 badSpace context
767 badSpace context
772− FreshLine nextDecl ->
773− "a fresh line (without any leading spaces) for " <>
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 [] [...]`"
780 Expecting next ->
769 Expecting next ->
781 case next of
770 case next of
782 Decl -> "a declaration, like `x = 5` or `type alias Model = { ... }`"
771 Decl -> "a declaration, like `x = 5` or `type alias Model = { ... }`"