@@ -649,184 +649,9 @@ toParseErrorReport source modul =
649649 toSpaceReport source space row col
650650
651651 ModuleBadEnd row col ->
652− case Code.whatIsNext source row col of
653− Code.Keyword keyword ->
654− let
655− region = toKeywordRegion row col keyword
656− in
657− Report.Report "RESERVED WORD" region [] $
658− Code.toSnippet source region Nothing
659− (
660− D.reflow $
661− "I got stuck on this reserved word:"
662− ,
663− D.reflow $
664− "The name `" ++ keyword ++ "` is reserved, so try using a different name?"
665− )
666−
667− Code.Operator op ->
668− let
669− region = toKeywordRegion row col op
670− in
671− Report.Report "UNEXPECTED SYMBOL" region [] $
672− Code.toSnippet source region Nothing
673− (
674− D.reflow $
675− "I ran into an unexpected symbol:"
676− ,
677− D.reflow $
678− "I was not expecting to see a " ++ op ++ " here. Try deleting it? Maybe\
679− \ I can give a better hint from there?"
680− )
681−
682− Code.Close term bracket ->
683− let
684− region = toRegion row col
685− in
686− Report.Report ("UNEXPECTED " ++ map Char.toUpper term) region [] $
687− Code.toSnippet source region Nothing
688− (
689− D.reflow $
690− "I ran into an unexpected " ++ term ++ ":"
691− ,
692− D.reflow $
693− "This " ++ bracket : " does not match up with an earlier open " ++ term ++ ". Try deleting it?"
694− )
695−
696− Code.Lower c cs ->
697− let
698− region = toKeywordRegion row col (c:cs)
699− in
700− Report.Report "UNEXPECTED NAME" region [] $
701− Code.toSnippet source region Nothing
702− (
703− D.reflow $
704− "I got stuck on this name:"
705− ,
706− D.reflow $
707− "It is confusing me a lot! Normally I can give fairly specific hints, but\
708− \ something is really tripping me up this time."
709− )
710−
711− Code.Upper c cs ->
712− let
713− region = toKeywordRegion row col (c:cs)
714− in
715− Report.Report "UNEXPECTED NAME" region [] $
716− Code.toSnippet source region Nothing
717− (
718− D.reflow $
719− "I got stuck on this name:"
720− ,
721− D.reflow $
722− "It is confusing me a lot! Normally I can give fairly specific hints, but\
723− \ something is really tripping me up this time."
724− )
725−
726− Code.Other maybeChar ->
727− let
728− region = toRegion row col
729− in
730− case maybeChar of
731− Just ';' ->
732− Report.Report "UNEXPECTED SEMICOLON" region [] $
733− Code.toSnippet source region Nothing
734− (
735− D.reflow $
736− "I got stuck on this semicolon:"
737− ,
738− D.stack
739− [ D.reflow $ "Try removing it?"
740− , D.toSimpleNote $
741− "Some languages require semicolons at the end of each statement. These are\
742− \ often called C-like languages, and they usually share a lot of language design\
743− \ choices. (E.g. side-effects, for loops, etc.) Elm manages effects with commands\
744− \ and subscriptions instead, so there is no special syntax for \"statements\" and\
745− \ therefore no need to use semicolons to separate them. I think this will make\
746− \ more sense as you work through <https://guide.elm-lang.org> though!"
747− ]
748− )
749−
750− Just ',' ->
751− Report.Report "UNEXPECTED COMMA" region [] $
752− Code.toSnippet source region Nothing
753− (
754− D.reflow $
755− "I got stuck on this comma:"
756− ,
757− D.stack
758− [ D.reflow $
759− "I do not think I am parsing a list or tuple right now. Try deleting the comma?"
760− , D.toSimpleNote $
761− "If this is supposed to be part of a list, the problem may be a bit earlier.\
762− \ Perhaps the opening [ is missing? Or perhaps some value in the list has an extra\
763− \ closing ] that is making me think the list ended earlier? The same kinds of\
764− \ things could be going wrong if this is supposed to be a tuple."
765− ]
766− )
767−
768− Just '`' ->
769− Report.Report "UNEXPECTED CHARACTER" region [] $
770− Code.toSnippet source region Nothing
771− (
772− D.reflow $
773− "I got stuck on this character:"
774− ,
775− D.stack
776− [ D.reflow $
777− "It is not used for anything in Elm syntax. It is used for multi-line strings in\
778− \ some languages though, so if you want a string that spans multiple lines, you\
779− \ can use Elm's multi-line string syntax like this:"
780− , D.dullyellow $ D.indent 4 $ D.vcat $
781− [ "\"\"\""
782− , "# Multi-line Strings"
783− , ""
784− , "- start with triple double quotes"
785− , "- write whatever you want"
786− , "- no need to escape newlines or double quotes"
787− , "- end with triple double quotes"
788− , "\"\"\""
789− ]
790− , D.reflow $
791− "Otherwise I do not know what is going on! Try removing the character?"
792− ]
793− )
794−
795− Just '$' ->
796− Report.Report "UNEXPECTED SYMBOL" region [] $
797− Code.toSnippet source region Nothing
798− (
799− D.reflow $
800− "I got stuck on this dollar sign:"
801− ,
802− D.reflow $
803− "It is not used for anything in Elm syntax. Are you coming from a language where\
804− \ dollar signs can be used in variable names? If so, try a name that (1) starts\
805− \ with a letter and (2) only contains letters, numbers, and underscores."
806− )
807−
808− Just c | elem c ['#','@','!','%','~'] ->
809− Report.Report "UNEXPECTED SYMBOL" region [] $
810− Code.toSnippet source region Nothing
811− (
812− D.reflow $
813− "I got stuck on this symbol:"
814− ,
815− D.reflow $
816− "It is not used for anything in Elm syntax. Try removing it?"
817− )
818−
819− _ ->
820− Report.Report "SYNTAX PROBLEM" region [] $
821− Code.toSnippet source region Nothing
822− (
823− D.reflow $
824− "I got stuck here:"
825− ,
826− D.reflow $
827− "Whatever I am running into is confusing me a lot! Normally I can give fairly\
828− \ specific hints, but something is really tripping me up this time."
829− )
652+ if col == 1
653+ then toDeclStartReport source row col
654+ else toWeirdEndReport source row col
830655
831656 ModuleProblem row col ->
832657 let
@@ -1100,6 +925,192 @@ toParseErrorReport source modul =
1100925
1101926
1102927
928+-- WEIRD END
929+
930+
931+toWeirdEndReport :: Code.Source -> Row -> Col -> Report.Report
932+toWeirdEndReport source row col =
933+ case Code.whatIsNext source row col of
934+ Code.Keyword keyword ->
935+ let
936+ region = toKeywordRegion row col keyword
937+ in
938+ Report.Report "RESERVED WORD" region [] $
939+ Code.toSnippet source region Nothing
940+ (
941+ D.reflow $
942+ "I got stuck on this reserved word:"
943+ ,
944+ D.reflow $
945+ "The name `" ++ keyword ++ "` is reserved, so try using a different name?"
946+ )
947+
948+ Code.Operator op ->
949+ let
950+ region = toKeywordRegion row col op
951+ in
952+ Report.Report "UNEXPECTED SYMBOL" region [] $
953+ Code.toSnippet source region Nothing
954+ (
955+ D.reflow $
956+ "I ran into an unexpected symbol:"
957+ ,
958+ D.reflow $
959+ "I was not expecting to see a " ++ op ++ " here. Try deleting it? Maybe\
960+ \ I can give a better hint from there?"
961+ )
962+
963+ Code.Close term bracket ->
964+ let
965+ region = toRegion row col
966+ in
967+ Report.Report ("UNEXPECTED " ++ map Char.toUpper term) region [] $
968+ Code.toSnippet source region Nothing
969+ (
970+ D.reflow $
971+ "I ran into an unexpected " ++ term ++ ":"
972+ ,
973+ D.reflow $
974+ "This " ++ bracket : " does not match up with an earlier open " ++ term ++ ". Try deleting it?"
975+ )
976+
977+ Code.Lower c cs ->
978+ let
979+ region = toKeywordRegion row col (c:cs)
980+ in
981+ Report.Report "UNEXPECTED NAME" region [] $
982+ Code.toSnippet source region Nothing
983+ (
984+ D.reflow $
985+ "I got stuck on this name:"
986+ ,
987+ D.reflow $
988+ "It is confusing me a lot! Normally I can give fairly specific hints, but\
989+ \ something is really tripping me up this time."
990+ )
991+
992+ Code.Upper c cs ->
993+ let
994+ region = toKeywordRegion row col (c:cs)
995+ in
996+ Report.Report "UNEXPECTED NAME" region [] $
997+ Code.toSnippet source region Nothing
998+ (
999+ D.reflow $
1000+ "I got stuck on this name:"
1001+ ,
1002+ D.reflow $
1003+ "It is confusing me a lot! Normally I can give fairly specific hints, but\
1004+ \ something is really tripping me up this time."
1005+ )
1006+
1007+ Code.Other maybeChar ->
1008+ let
1009+ region = toRegion row col
1010+ in
1011+ case maybeChar of
1012+ Just ';' ->
1013+ Report.Report "UNEXPECTED SEMICOLON" region [] $
1014+ Code.toSnippet source region Nothing
1015+ (
1016+ D.reflow $
1017+ "I got stuck on this semicolon:"
1018+ ,
1019+ D.stack
1020+ [ D.reflow $ "Try removing it?"
1021+ , D.toSimpleNote $
1022+ "Some languages require semicolons at the end of each statement. These are\
1023+ \ often called C-like languages, and they usually share a lot of language design\
1024+ \ choices. (E.g. side-effects, for loops, etc.) Elm manages effects with commands\
1025+ \ and subscriptions instead, so there is no special syntax for \"statements\" and\
1026+ \ therefore no need to use semicolons to separate them. I think this will make\
1027+ \ more sense as you work through <https://guide.elm-lang.org> though!"
1028+ ]
1029+ )
1030+
1031+ Just ',' ->
1032+ Report.Report "UNEXPECTED COMMA" region [] $
1033+ Code.toSnippet source region Nothing
1034+ (
1035+ D.reflow $
1036+ "I got stuck on this comma:"
1037+ ,
1038+ D.stack
1039+ [ D.reflow $
1040+ "I do not think I am parsing a list or tuple right now. Try deleting the comma?"
1041+ , D.toSimpleNote $
1042+ "If this is supposed to be part of a list, the problem may be a bit earlier.\
1043+ \ Perhaps the opening [ is missing? Or perhaps some value in the list has an extra\
1044+ \ closing ] that is making me think the list ended earlier? The same kinds of\
1045+ \ things could be going wrong if this is supposed to be a tuple."
1046+ ]
1047+ )
1048+
1049+ Just '`' ->
1050+ Report.Report "UNEXPECTED CHARACTER" region [] $
1051+ Code.toSnippet source region Nothing
1052+ (
1053+ D.reflow $
1054+ "I got stuck on this character:"
1055+ ,
1056+ D.stack
1057+ [ D.reflow $
1058+ "It is not used for anything in Elm syntax. It is used for multi-line strings in\
1059+ \ some languages though, so if you want a string that spans multiple lines, you\
1060+ \ can use Elm's multi-line string syntax like this:"
1061+ , D.dullyellow $ D.indent 4 $ D.vcat $
1062+ [ "\"\"\""
1063+ , "# Multi-line Strings"
1064+ , ""
1065+ , "- start with triple double quotes"
1066+ , "- write whatever you want"
1067+ , "- no need to escape newlines or double quotes"
1068+ , "- end with triple double quotes"
1069+ , "\"\"\""
1070+ ]
1071+ , D.reflow $
1072+ "Otherwise I do not know what is going on! Try removing the character?"
1073+ ]
1074+ )
1075+
1076+ Just '$' ->
1077+ Report.Report "UNEXPECTED SYMBOL" region [] $
1078+ Code.toSnippet source region Nothing
1079+ (
1080+ D.reflow $
1081+ "I got stuck on this dollar sign:"
1082+ ,
1083+ D.reflow $
1084+ "It is not used for anything in Elm syntax. Are you coming from a language where\
1085+ \ dollar signs can be used in variable names? If so, try a name that (1) starts\
1086+ \ with a letter and (2) only contains letters, numbers, and underscores."
1087+ )
1088+
1089+ Just c | elem c ['#','@','!','%','~'] ->
1090+ Report.Report "UNEXPECTED SYMBOL" region [] $
1091+ Code.toSnippet source region Nothing
1092+ (
1093+ D.reflow $
1094+ "I got stuck on this symbol:"
1095+ ,
1096+ D.reflow $
1097+ "It is not used for anything in Elm syntax. Try removing it?"
1098+ )
1099+
1100+ _ ->
1101+ Report.Report "SYNTAX PROBLEM" region [] $
1102+ Code.toSnippet source region Nothing
1103+ (
1104+ D.reflow $
1105+ "I got stuck here:"
1106+ ,
1107+ D.reflow $
1108+ "Whatever I am running into is confusing me a lot! Normally I can give fairly\
1109+ \ specific hints, but something is really tripping me up this time."
1110+ )
1111+
1112+
1113+
11031114-- IMPORTS
11041115
11051116
@@ -1432,189 +1443,194 @@ toDeclarationsReport :: Code.Source -> Decl -> Report.Report
14321443toDeclarationsReport source decl =
14331444 case decl of
14341445 DeclStart row col ->
1435− case Code.whatIsNext source row col of
1436− Code.Close term bracket ->
1437− let
1438− region = toRegion row col
1439− in
1440− Report.Report ("STRAY " ++ map Char.toUpper term) region [] $
1441− Code.toSnippet source region Nothing
1442− (
1443− D.reflow $
1444− "I was not expecting to see a " ++ term ++ " here:"
1445− , D.reflow $
1446− "This " ++ bracket : " does not match up with an earlier open " ++ term ++ ". Try deleting it?"
1447− )
1446+ toDeclStartReport source row col
14481447
1449− Code.Keyword keyword ->
1450− let
1451− region = toKeywordRegion row col keyword
1452− in
1453− Report.Report "RESERVED WORD" region [] $
1454− Code.toSnippet source region Nothing
1455− (
1456− D.reflow $
1457− "I was not expecting to run into the `" ++ keyword ++ "` keyword here:"
1458− ,
1459− case keyword of
1460− "import" ->
1461− D.reflow $
1462− "It is reserved for declaring imports at the top of your module. If you want\
1463− \ another import, try moving it up top with the other imports. If you want to\
1464− \ define a value or function, try changing the name to something else!"
1465−
1466− "case" ->
1467− D.stack
1468− [ D.reflow $
1469− "It is reserved for writing `case` expressions. Try using a different name?"
1470− , D.toSimpleNote $
1471− "If you are trying to write a `case` expression, it needs to be part of a\
1472− \ definition. So you could write something like this instead:"
1473− , D.indent 4 $ D.vcat $
1474− [ D.indent 0 $ D.fillSep ["getWidth","maybeWidth","="]
1475− , D.indent 2 $ D.fillSep [D.cyan "case","maybeWidth",D.cyan "of"]
1476− , D.indent 4 $ D.fillSep [D.blue "Just","width","->"]
1477− , D.indent 6 $ D.fillSep ["width","+",D.dullyellow "200"]
1478− , ""
1479− , D.indent 4 $ D.fillSep [D.blue "Nothing","->"]
1480− , D.indent 6 $ D.fillSep [D.dullyellow "400"]
1481− ]
1482− , D.reflow $
1483− "This defines a `getWidth` function that you can use elsewhere in your program."
1484− ]
1448+ DeclSpace space row col ->
1449+ toSpaceReport source space row col
14851450
1486− "if" ->
1487− D.stack
1488− [ D.reflow $
1489− "It is reserved for writing `if` expressions. Try using a different name?"
1490− , D.toSimpleNote $
1491− "If you are trying to write an `if` expression, it needs to be part of a\
1492− \ definition. So you could write something like this instead:"
1493− , D.indent 4 $ D.vcat $
1494− [ "greet name ="
1495− , D.fillSep $
1496− [" "
1497− ,D.cyan "if","name","==",D.dullyellow "\"Abraham Lincoln\""
1498− ,D.cyan "then",D.dullyellow "\"Greetings Mr. President.\""
1499− ,D.cyan "else",D.dullyellow "\"Hey!\""
1500− ]
1501− ]
1502− , D.reflow $
1503− "This defines a `reviewPowerLevel` function that you can use elsewhere in your program."
1504− ]
1451+ Port port_ row col ->
1452+ toPortReport source port_ row col
15051453
1506− _ ->
1507− D.reflow $
1508− "It is a reserved word. Try changing the name to something else?"
1509− )
1454+ DeclType declType row col ->
1455+ toDeclTypeReport source declType row col
15101456
1511− Code.Upper c cs ->
1512− let
1513− region = toRegion row col
1514− in
1515− Report.Report "UNEXPECTED CAPITAL LETTER" region [] $
1516− Code.toSnippet source region Nothing
1517− (
1518− D.reflow $
1519− "Declarations always start with a lower-case letter, so I am getting stuck here:"
1520− ,
1521− D.stack
1522− [ D.fillSep $
1523− ["Try","a","name","like"
1524− ,D.green (D.fromChars (Char.toLower c : cs))
1525− ,"instead?"
1526− ]
1527− , D.toSimpleNote $
1528− "Here are a couple valid declarations for reference:"
1529− , D.indent 4 $ D.vcat $
1530− [ "greet : String -> String"
1531− , "greet name ="
1532− , " " <> D.dullyellow "\"Hello \"" <> " ++ name ++ " <> D.dullyellow "\"!\""
1533− , ""
1534− , D.cyan "type" <> " User = Anonymous | LoggedIn String"
1535− ]
1536− , D.reflow $
1537− "Notice that they always start with a lower-case letter. Capitalization matters!"
1538− ]
1539− )
1457+ DeclDef name declDef row col ->
1458+ toDeclDefReport source name declDef row col
15401459
1541− Code.Other (Just char) | elem char ['(', '{', '[', '+', '-', '*', '/', '^', '&', '|', '"', '\'', '!', '@', '#', '$', '%'] ->
1542− let
1543− region = toRegion row col
1544− in
1545− Report.Report "UNEXPECTED SYMBOL" region [] $
1546− Code.toSnippet source region Nothing
1547− (
1460+ DeclFreshLineAfterDocComment row col ->
1461+ let
1462+ region = toRegion row col
1463+ in
1464+ Report.Report "EXPECTING DECLARATION" region [] $
1465+ Code.toSnippet source region Nothing
1466+ (
1467+ D.reflow $
1468+ "I just saw a doc comment, but then I got stuck here:"
1469+ ,
1470+ D.reflow $
1471+ "I was expecting to see the corresponding declaration next, starting on a fresh\
1472+ \ line with no indentation."
1473+ )
1474+
1475+
1476+toDeclStartReport :: Code.Source -> Row -> Col -> Report.Report
1477+toDeclStartReport source row col =
1478+ case Code.whatIsNext source row col of
1479+ Code.Close term bracket ->
1480+ let
1481+ region = toRegion row col
1482+ in
1483+ Report.Report ("STRAY " ++ map Char.toUpper term) region [] $
1484+ Code.toSnippet source region Nothing
1485+ (
1486+ D.reflow $
1487+ "I was not expecting to see a " ++ term ++ " here:"
1488+ , D.reflow $
1489+ "This " ++ bracket : " does not match up with an earlier open " ++ term ++ ". Try deleting it?"
1490+ )
1491+
1492+ Code.Keyword keyword ->
1493+ let
1494+ region = toKeywordRegion row col keyword
1495+ in
1496+ Report.Report "RESERVED WORD" region [] $
1497+ Code.toSnippet source region Nothing
1498+ (
1499+ D.reflow $
1500+ "I was not expecting to run into the `" ++ keyword ++ "` keyword here:"
1501+ ,
1502+ case keyword of
1503+ "import" ->
15481504 D.reflow $
1549− "I am getting stuck because this line starts with the " ++ [char] ++ " symbol:"
1550− ,
1505+ "It is reserved for declaring imports at the top of your module. If you want\
1506+ \ another import, try moving it up top with the other imports. If you want to\
1507+ \ define a value or function, try changing the name to something else!"
1508+
1509+ "case" ->
15511510 D.stack
15521511 [ D.reflow $
1553− "When a line has no spaces at the beginning, I expect it to be a declaration like one of these:"
1512+ "It is reserved for writing `case` expressions. Try using a different name?"
1513+ , D.toSimpleNote $
1514+ "If you are trying to write a `case` expression, it needs to be part of a\
1515+ \ definition. So you could write something like this instead:"
15541516 , D.indent 4 $ D.vcat $
1555− [ "greet : String -> String"
1556− , "greet name ="
1557− , " " <> D.dullyellow "\"Hello \"" <> " ++ name ++ " <> D.dullyellow "\"!\""
1517+ [ D.indent 0 $ D.fillSep ["getWidth","maybeWidth","="]
1518+ , D.indent 2 $ D.fillSep [D.cyan "case","maybeWidth",D.cyan "of"]
1519+ , D.indent 4 $ D.fillSep [D.blue "Just","width","->"]
1520+ , D.indent 6 $ D.fillSep ["width","+",D.dullyellow "200"]
15581521 , ""
1559− , D.cyan "type" <> " User = Anonymous | LoggedIn String"
1522+ , D.indent 4 $ D.fillSep [D.blue "Nothing","->"]
1523+ , D.indent 6 $ D.fillSep [D.dullyellow "400"]
15601524 ]
15611525 , D.reflow $
1562− "If this is not supposed to be a declaration, try adding some spaces before it?"
1526+ "This defines a `getWidth` function that you can use elsewhere in your program."
15631527 ]
1564− )
15651528
1566− _ ->
1567− let
1568− region = toRegion row col
1569− in
1570− Report.Report "WEIRD DECLARATION" region [] $
1571− Code.toSnippet source region Nothing
1572− (
1573− D.reflow $
1574− "I am trying to parse a declaration, but I am getting stuck here:"
1575− ,
1529+ "if" ->
15761530 D.stack
15771531 [ D.reflow $
1578− "I am not sure what is going wrong, so here are a couple valid declarations for reference:"
1532+ "It is reserved for writing `if` expressions. Try using a different name?"
1533+ , D.toSimpleNote $
1534+ "If you are trying to write an `if` expression, it needs to be part of a\
1535+ \ definition. So you could write something like this instead:"
15791536 , D.indent 4 $ D.vcat $
1580− [ "greet : String -> String"
1581− , "greet name ="
1582− , " " <> D.dullyellow "\"Hello \"" <> " ++ name ++ " <> D.dullyellow "\"!\""
1583− , ""
1584− , D.cyan "type" <> " User = Anonymous | LoggedIn String"
1537+ [ "greet name ="
1538+ , D.fillSep $
1539+ [" "
1540+ ,D.cyan "if","name","==",D.dullyellow "\"Abraham Lincoln\""
1541+ ,D.cyan "then",D.dullyellow "\"Greetings Mr. President.\""
1542+ ,D.cyan "else",D.dullyellow "\"Hey!\""
1543+ ]
15851544 ]
15861545 , D.reflow $
1587− "Try to make your declaration look like one of those?"
1546+ "This defines a `reviewPowerLevel` function that you can use elsewhere in your program."
15881547 ]
1589− )
1590−
1591− DeclSpace space row col ->
1592− toSpaceReport source space row col
1593−
1594− Port port_ row col ->
1595− toPortReport source port_ row col
1596−
1597− DeclType declType row col ->
1598− toDeclTypeReport source declType row col
15991548
1600− DeclDef name declDef row col ->
1601− toDeclDefReport source name declDef row col
1549+ _ ->
1550+ D.reflow $
1551+ "It is a reserved word. Try changing the name to something else?"
1552+ )
16021553
1603− DeclFreshLineAfterDocComment row col ->
1554+ Code.Upper c cs ->
16041555 let
16051556 region = toRegion row col
16061557 in
1607− Report.Report "EXPECTING DECLARATION" region [] $
1558+ Report.Report "UNEXPECTED CAPITAL LETTER" region [] $
16081559 Code.toSnippet source region Nothing
16091560 (
16101561 D.reflow $
1611− "I just saw a doc comment, but then I got stuck here:"
1562+ "Declarations always start with a lower-case letter, so I am getting stuck here:"
16121563 ,
1564+ D.stack
1565+ [ D.fillSep $
1566+ ["Try","a","name","like"
1567+ ,D.green (D.fromChars (Char.toLower c : cs))
1568+ ,"instead?"
1569+ ]
1570+ , D.toSimpleNote $
1571+ "Here are a couple valid declarations for reference:"
1572+ , D.indent 4 $ D.vcat $
1573+ [ "greet : String -> String"
1574+ , "greet name ="
1575+ , " " <> D.dullyellow "\"Hello \"" <> " ++ name ++ " <> D.dullyellow "\"!\""
1576+ , ""
1577+ , D.cyan "type" <> " User = Anonymous | LoggedIn String"
1578+ ]
1579+ , D.reflow $
1580+ "Notice that they always start with a lower-case letter. Capitalization matters!"
1581+ ]
1582+ )
1583+
1584+ Code.Other (Just char) | elem char ['(', '{', '[', '+', '-', '*', '/', '^', '&', '|', '"', '\'', '!', '@', '#', '$', '%'] ->
1585+ let
1586+ region = toRegion row col
1587+ in
1588+ Report.Report "UNEXPECTED SYMBOL" region [] $
1589+ Code.toSnippet source region Nothing
1590+ (
16131591 D.reflow $
1614− "I was expecting to see the corresponding declaration next, starting on a fresh\
1615− \ line with no indentation."
1592+ "I am getting stuck because this line starts with the " ++ [char] ++ " symbol:"
1593+ ,
1594+ D.stack
1595+ [ D.reflow $
1596+ "When a line has no spaces at the beginning, I expect it to be a declaration like one of these:"
1597+ , D.indent 4 $ D.vcat $
1598+ [ "greet : String -> String"
1599+ , "greet name ="
1600+ , " " <> D.dullyellow "\"Hello \"" <> " ++ name ++ " <> D.dullyellow "\"!\""
1601+ , ""
1602+ , D.cyan "type" <> " User = Anonymous | LoggedIn String"
1603+ ]
1604+ , D.reflow $
1605+ "If this is not supposed to be a declaration, try adding some spaces before it?"
1606+ ]
16161607 )
16171608
1609+ _ ->
1610+ let
1611+ region = toRegion row col
1612+ in
1613+ Report.Report "WEIRD DECLARATION" region [] $
1614+ Code.toSnippet source region Nothing
1615+ (
1616+ D.reflow $
1617+ "I am trying to parse a declaration, but I am getting stuck here:"
1618+ ,
1619+ D.stack
1620+ [ D.reflow $
1621+ "When a line has no spaces at the beginning, I expect it to be a declaration like one of these:"
1622+ , D.indent 4 $ D.vcat $
1623+ [ "greet : String -> String"
1624+ , "greet name ="
1625+ , " " <> D.dullyellow "\"Hello \"" <> " ++ name ++ " <> D.dullyellow "\"!\""
1626+ , ""
1627+ , D.cyan "type" <> " User = Anonymous | LoggedIn String"
1628+ ]
1629+ , D.reflow $
1630+ "Try to make your declaration look like one of those? Or if this is not\
1631+ \ supposed to be a declaration, try adding some spaces before it?"
1632+ ]
1633+ )
16181634
16191635
16201636-- PORT
@@ -2575,7 +2591,7 @@ toExprReport source context expr startRow startCol =
25752591 ,"give","a","more","specific","hint!"
25762592 ]
25772593 , D.toSimpleNote $
2578− "This can also happen if run into reserved words like `let` or `as` unexpectedly.\
2594+ "This can also happen if I run into reserved words like `let` or `as` unexpectedly.\
25792595 \ Or if I run into operators in unexpected spots. Point is, there are a\
25802596 \ couple ways I can get confused and give sort of weird advice!"
25812597 ]