@@ -649,156 +649,9 @@ toParseErrorReport source modul =
649 toSpaceReport source space row col
649 toSpaceReport source space row col
651 ModuleBadEnd row col ->
651 ModuleBadEnd row col ->
652− case Code.whatIsNext source row col of
652+ if col == 1
653− Code.Keyword keyword ->
653+ then toDeclStartReport source row col
654− let
654+ else toWeirdEndReport source row col
655− region = toKeywordRegion row col keyword
657− Report.Report "RESERVED WORD" region [] $
658− Code.toSnippet source region Nothing
661− "I got stuck on this reserved word:"
664− "The name `" ++ keyword ++ "` is reserved, so try using a different name?"
669− region = toKeywordRegion row col op
671− Report.Report "UNEXPECTED SYMBOL" region [] $
672− Code.toSnippet source region Nothing
675− "I ran into an unexpected symbol:"
678− "I was not expecting to see a " ++ op ++ " here. Try deleting it? Maybe\
679− \ I can give a better hint from there?"
682− Code.Close term bracket ->
684− region = toRegion row col
686− Report.Report ("UNEXPECTED " ++ map Char.toUpper term) region [] $
687− Code.toSnippet source region Nothing
690− "I ran into an unexpected " ++ term ++ ":"
693− "This " ++ bracket : " does not match up with an earlier open " ++ term ++ ". Try deleting it?"
696− Code.Other maybeChar ->
698− region = toRegion row col
702− Report.Report "UNEXPECTED SEMICOLON" region [] $
703− Code.toSnippet source region Nothing
706− "I got stuck on this semicolon:"
709− [ D.reflow $ "Try removing it?"
711− "Some languages require semicolons at the end of each statement. These are\
712− \ often called C-like languages, and they usually share a lot of language design\
713− \ choices. (E.g. side-effects, for loops, etc.) Elm manages effects with commands\
714− \ and subscriptions instead, so there is no special syntax for \"statements\" and\
715− \ therefore no need to use semicolons to separate them. I think this will make\
716− \ more sense as you work through <https://guide.elm-lang.org> though!"
721− Report.Report "UNEXPECTED COMMA" region [] $
722− Code.toSnippet source region Nothing
725− "I got stuck on this comma:"
729− "I do not think I am parsing a list or tuple right now. Try deleting the comma?"
731− "If this is supposed to be part of a list, the problem may be a bit earlier.\
732− \ Perhaps the opening [ is missing? Or perhaps some value in the list has an extra\
733− \ closing ] that is making me think the list ended earlier? The same kinds of\
734− \ things could be going wrong if this is supposed to be a tuple."
739− Report.Report "UNEXPECTED CHARACTER" region [] $
740− Code.toSnippet source region Nothing
743− "I got stuck on this character:"
747− "It is not used for anything in Elm syntax. It is used for multi-line strings in\
748− \ some languages though, so if you want a string that spans multiple lines, you\
749− \ can use Elm's multi-line string syntax like this:"
751− [ D.fillSep [D.green "markdown","=",D.dullyellow "\"\"\""]
753− , D.dullyellow "# Multi-line Strings"
755− , D.dullyellow "- start with triple double quotes"
756− , D.dullyellow "- write whatever you want"
757− , D.dullyellow "- no need to escape newlines or double quotes"
758− , D.dullyellow "- end with triple double quotes"
760− , D.dullyellow "\"\"\""
763− "Otherwise I do not know what is going on! Try removing the character?"
768− Report.Report "UNEXPECTED SYMBOL" region [] $
769− Code.toSnippet source region Nothing
772− "I got stuck on this dollar sign:"
775− "It is not used for anything in Elm syntax. Are you coming from a language where\
776− \ dollar signs can be used in variable names? If so, try a name that (1) starts\
777− \ with a letter and (2) only contains letters, numbers, and underscores."
780− Just c | elem c ['#','@','!','%','~'] ->
781− Report.Report "UNEXPECTED SYMBOL" region [] $
782− Code.toSnippet source region Nothing
785− "I got stuck on this symbol:"
788− "It is not used for anything in Elm syntax. Try removing it?"
792− Report.Report "SYNTAX PROBLEM" region [] $
793− Code.toSnippet source region Nothing
799− "Whatever I am running into is confusing me a lot! Normally I can give fairly\
800− \ specific hints, but something is really tripping me up this time."
803 ModuleProblem row col ->
656 ModuleProblem row col ->
@@ -944,11 +797,11 @@ toParseErrorReport source modul =
944 [ D.reflow $
797 [ D.reflow $
945 "I am not sure what is going on, but I recommend starting an Elm\
798 "I am not sure what is going on, but I recommend starting an Elm\
946 \ file with the following lines:"
799 \ file with the following lines:"
947− , D.vcat
800+ , D.indent 4 $ D.vcat $
948 [ D.fillSep [D.cyan "import","Html"]
801 [ D.fillSep [D.cyan "import","Html"]
950− , D.fillSep [D.green "main","="]
803+ , "main ="
951− , D.indent 2 $ D.fillSep [D.cyan "Html" <> ".text",D.dullyellow "\"Hello!\""]
804+ , " Html.text " <> D.dullyellow "\"Hello!\""
953 , D.reflow $
806 , D.reflow $
954 "You should be able to copy those lines directly into your file. Check out the\
807 "You should be able to copy those lines directly into your file. Check out the\
@@ -977,11 +830,12 @@ toParseErrorReport source modul =
977 , D.indent 4 $ D.vcat $
830 , D.indent 4 $ D.vcat $
978 [ D.fillSep [D.cyan "import","Dict"]
831 [ D.fillSep [D.cyan "import","Dict"]
979 , D.fillSep [D.cyan "import","Maybe"]
832 , D.fillSep [D.cyan "import","Maybe"]
980− , D.fillSep [D.cyan "import","Html.Attributes"]
833+ , D.fillSep [D.cyan "import","Html.Attributes",D.cyan "as","A"]
981− , D.fillSep [D.cyan "import","Json.Decode"]
834+ , D.fillSep [D.cyan "import","Json.Decode",D.cyan "exposing","(..)"]
983 , D.reflow $
836 , D.reflow $
984 "Notice that the module names all start with capital letters. That is required!"
837 "Notice that the module names all start with capital letters. That is required!"
838+ , D.reflowLink "Read" "imports" "to learn more."
@@ -1008,6 +862,7 @@ toParseErrorReport source modul =
1009 , D.reflow $
863 , D.reflow $
1010 "Notice that the alias always starts with a capital letter. That is required!"
864 "Notice that the alias always starts with a capital letter. That is required!"
865+ , D.reflowLink "Read" "imports" "to learn more."
@@ -1070,6 +925,192 @@ toParseErrorReport source modul =
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 ->
936+ region = toKeywordRegion row col keyword
938+ Report.Report "RESERVED WORD" region [] $
939+ Code.toSnippet source region Nothing
942+ "I got stuck on this reserved word:"
945+ "The name `" ++ keyword ++ "` is reserved, so try using a different name?"
950+ region = toKeywordRegion row col op
952+ Report.Report "UNEXPECTED SYMBOL" region [] $
953+ Code.toSnippet source region Nothing
956+ "I ran into an unexpected symbol:"
959+ "I was not expecting to see a " ++ op ++ " here. Try deleting it? Maybe\
960+ \ I can give a better hint from there?"
963+ Code.Close term bracket ->
965+ region = toRegion row col
967+ Report.Report ("UNEXPECTED " ++ map Char.toUpper term) region [] $
968+ Code.toSnippet source region Nothing
971+ "I ran into an unexpected " ++ term ++ ":"
974+ "This " ++ bracket : " does not match up with an earlier open " ++ term ++ ". Try deleting it?"
979+ region = toKeywordRegion row col (c:cs)
981+ Report.Report "UNEXPECTED NAME" region [] $
982+ Code.toSnippet source region Nothing
985+ "I got stuck on this name:"
988+ "It is confusing me a lot! Normally I can give fairly specific hints, but\
989+ \ something is really tripping me up this time."
994+ region = toKeywordRegion row col (c:cs)
996+ Report.Report "UNEXPECTED NAME" region [] $
997+ Code.toSnippet source region Nothing
1000+ "I got stuck on this name:"
1003+ "It is confusing me a lot! Normally I can give fairly specific hints, but\
1004+ \ something is really tripping me up this time."
1007+ Code.Other maybeChar ->
1009+ region = toRegion row col
1013+ Report.Report "UNEXPECTED SEMICOLON" region [] $
1014+ Code.toSnippet source region Nothing
1017+ "I got stuck on this semicolon:"
1020+ [ D.reflow $ "Try removing it?"
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!"
1032+ Report.Report "UNEXPECTED COMMA" region [] $
1033+ Code.toSnippet source region Nothing
1036+ "I got stuck on this comma:"
1040+ "I do not think I am parsing a list or tuple right now. Try deleting the comma?"
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."
1050+ Report.Report "UNEXPECTED CHARACTER" region [] $
1051+ Code.toSnippet source region Nothing
1054+ "I got stuck on this character:"
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 $
1063+ , "# Multi-line Strings"
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"
1072+ "Otherwise I do not know what is going on! Try removing the character?"
1077+ Report.Report "UNEXPECTED SYMBOL" region [] $
1078+ Code.toSnippet source region Nothing
1081+ "I got stuck on this dollar sign:"
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."
1089+ Just c | elem c ['#','@','!','%','~'] ->
1090+ Report.Report "UNEXPECTED SYMBOL" region [] $
1091+ Code.toSnippet source region Nothing
1094+ "I got stuck on this symbol:"
1097+ "It is not used for anything in Elm syntax. Try removing it?"
1101+ Report.Report "SYNTAX PROBLEM" region [] $
1102+ Code.toSnippet source region Nothing
1105+ "I got stuck here:"
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."
1073-- IMPORTS
1114-- IMPORTS
@@ -1095,6 +1136,7 @@ toImportReport source row col =
1096 , D.reflow $
1137 , D.reflow $
1097 "You are probably trying to import a different module, but try to make it look like one of these examples!"
1138 "You are probably trying to import a different module, but try to make it look like one of these examples!"
1139+ , D.reflowLink "Read" "imports" "to learn more."
@@ -1401,114 +1443,7 @@ toDeclarationsReport :: Code.Source -> Decl -> Report.Report
1401toDeclarationsReport source decl =
1443toDeclarationsReport source decl =
1402 case decl of
1444 case decl of
1403 DeclStart row col ->
1445 DeclStart row col ->
1404− case Code.whatIsNext source row col of
1446+ toDeclStartReport source row col
1405− Code.Close term bracket ->
1407− region = toRegion row col
1409− Report.Report ("STRAY " ++ map Char.toUpper term) region [] $
1410− Code.toSnippet source region Nothing
1413− "I was not expecting to see a " ++ term ++ " here:"
1415− "This " ++ bracket : " does not match up with an earlier open " ++ term ++ ". Try deleting it?"
1418− Code.Keyword keyword ->
1420− region = toKeywordRegion row col keyword
1422− Report.Report "RESERVED WORD" region [] $
1423− Code.toSnippet source region Nothing
1426− "I was not expecting to run into the `" ++ keyword ++ "` keyword here:"
1431− "It is reserved for declaring imports at the top of your module. If you want\
1432− \ another import, try moving it up top with the other imports. If you want to\
1433− \ define a value or function, try changing the name to something else!"
1438− "It is reserved for writing `case` expressions. Try using a different name?"
1440− "If you are trying to write a `case` expression, it needs to be part of a\
1441− \ definition. So you could write something like this instead:"
1443− [ D.indent 0 $ D.fillSep [D.green "getWidth","maybeWidth","="]
1444− , D.indent 2 $ D.fillSep [D.cyan "case","maybeWidth",D.cyan "of"]
1445− , D.indent 4 $ D.fillSep [D.blue "Just","width","->"]
1446− , D.indent 6 $ D.fillSep ["width","+",D.dullyellow "200"]
1448− , D.indent 4 $ D.fillSep [D.blue "Nothing","->"]
1449− , D.indent 6 $ D.fillSep [D.dullyellow "400"]
1452− "This defines a `getWidth` function that we can use elsewhere in our program."
1458− "It is reserved for writing `if` expressions. Try using a different name?"
1460− "If you are trying to write an `if` expression, it needs to be part of a\
1461− \ definition. So you could write something like this instead:"
1463− [ D.indent 0 $ D.fillSep [D.green "reviewPowerLevel","powerLevel","="]
1464− , D.indent 2 $ D.fillSep $
1465− [D.cyan "if","powerLevel",">",D.dullyellow "9000"
1466− ,D.cyan "then",D.dullyellow "\"OVER 9000!!!\""
1467− ,D.cyan "else",D.dullyellow "\"not bad\""
1471− "This defines a `reviewPowerLevel` function that we can use elsewhere in our program."
1476− "It is a reserved word. Try changing the name to something else?"
1481− region = toRegion row col
1483− Report.Report "SYNTAX PROBLEM" region [] $
1484− Code.toSnippet source region Nothing
1487− "I was expecting to see a declaration, but I am getting stuck here:"
1490− [ case Code.whatIsNext source row col of
1491− Code.Other (Just char) | Char.isUpper char ->
1493− "All declarations start with lower-case letters in Elm, so maybe this letter can\
1494− \ be changed to lower-case?"
1498− "Declarations normally start with a lower-case name or the `type` keyword."
1500− "Here are a couple valid declarations for reference:"
1502− [ D.fillSep [D.green "add",":","Int","->","Int","->","Int"]
1503− , D.fillSep [D.green "add","x","y","="]
1504− , D.fillSep [" ","x","+","y"]
1506− , D.fillSep [D.cyan "type",D.green "User","=","Anonymous","|","LoggedIn String"]
1508− "Notice that these declarations start with lower-case letters. Capitalization\
1509− \ makes a difference in Elm!"
1513 DeclSpace space row col ->
1448 DeclSpace space row col ->
1514 toSpaceReport source space row col
1449 toSpaceReport source space row col
@@ -1538,6 +1473,165 @@ toDeclarationsReport source decl =
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 ->
1481+ region = toRegion row col
1483+ Report.Report ("STRAY " ++ map Char.toUpper term) region [] $
1484+ Code.toSnippet source region Nothing
1487+ "I was not expecting to see a " ++ term ++ " here:"
1489+ "This " ++ bracket : " does not match up with an earlier open " ++ term ++ ". Try deleting it?"
1492+ Code.Keyword keyword ->
1494+ region = toKeywordRegion row col keyword
1496+ Report.Report "RESERVED WORD" region [] $
1497+ Code.toSnippet source region Nothing
1500+ "I was not expecting to run into the `" ++ keyword ++ "` keyword here:"
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!"
1512+ "It is reserved for writing `case` expressions. Try using a different name?"
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:"
1516+ , D.indent 4 $ D.vcat $
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"]
1522+ , D.indent 4 $ D.fillSep [D.blue "Nothing","->"]
1523+ , D.indent 6 $ D.fillSep [D.dullyellow "400"]
1526+ "This defines a `getWidth` function that you can use elsewhere in your program."
1532+ "It is reserved for writing `if` expressions. Try using a different name?"
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:"
1536+ , D.indent 4 $ D.vcat $
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!\""
1546+ "This defines a `reviewPowerLevel` function that you can use elsewhere in your program."
1551+ "It is a reserved word. Try changing the name to something else?"
1556+ region = toRegion row col
1558+ Report.Report "UNEXPECTED CAPITAL LETTER" region [] $
1559+ Code.toSnippet source region Nothing
1562+ "Declarations always start with a lower-case letter, so I am getting stuck here:"
1566+ ["Try","a","name","like"
1567+ ,D.green (D.fromChars (Char.toLower c : cs))
1571+ "Here are a couple valid declarations for reference:"
1572+ , D.indent 4 $ D.vcat $
1573+ [ "greet : String -> String"
1575+ , " " <> D.dullyellow "\"Hello \"" <> " ++ name ++ " <> D.dullyellow "\"!\""
1577+ , D.cyan "type" <> " User = Anonymous | LoggedIn String"
1580+ "Notice that they always start with a lower-case letter. Capitalization matters!"
1584+ Code.Other (Just char) | elem char ['(', '{', '[', '+', '-', '*', '/', '^', '&', '|', '"', '\'', '!', '@', '#', '$', '%'] ->
1586+ region = toRegion row col
1588+ Report.Report "UNEXPECTED SYMBOL" region [] $
1589+ Code.toSnippet source region Nothing
1592+ "I am getting stuck because this line starts with the " ++ [char] ++ " symbol:"
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"
1600+ , " " <> D.dullyellow "\"Hello \"" <> " ++ name ++ " <> D.dullyellow "\"!\""
1602+ , D.cyan "type" <> " User = Anonymous | LoggedIn String"
1605+ "If this is not supposed to be a declaration, try adding some spaces before it?"
1611+ region = toRegion row col
1613+ Report.Report "WEIRD DECLARATION" region [] $
1614+ Code.toSnippet source region Nothing
1617+ "I am trying to parse a declaration, but I am getting stuck here:"
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"
1625+ , " " <> D.dullyellow "\"Hello \"" <> " ++ name ++ " <> D.dullyellow "\"!\""
1627+ , D.cyan "type" <> " User = Anonymous | LoggedIn String"
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?"
@@ -1664,7 +1758,7 @@ toPortReport source port_ startRow startCol =
1664 [ D.reflow $
1758 [ D.reflow $
1665 "I was expecting to see a type next. Here are examples of outgoing and\
1759 "I was expecting to see a type next. Here are examples of outgoing and\
1666 \ incoming ports for reference:"
1760 \ incoming ports for reference:"
1667− , D.vcat
1761+ , D.indent 4 $ D.vcat $
1668 [ D.fillSep [D.cyan "port","send",":","String -> Cmd msg"]
1762 [ D.fillSep [D.cyan "port","send",":","String -> Cmd msg"]
1669 , D.fillSep [D.cyan "port","receive",":","(String -> msg) -> Sub msg"]
1763 , D.fillSep [D.cyan "port","receive",":","(String -> msg) -> Sub msg"]
@@ -1683,7 +1777,7 @@ portNote =
1684 [ D.toSimpleNote $
1778 [ D.toSimpleNote $
1685 "Here are some example `port` declarations for reference:"
1779 "Here are some example `port` declarations for reference:"
1686− , D.vcat
1780+ , D.indent 4 $ D.vcat $
1687 [ D.fillSep [D.cyan "port","send",":","String -> Cmd msg"]
1781 [ D.fillSep [D.cyan "port","send",":","String -> Cmd msg"]
1688 , D.fillSep [D.cyan "port","receive",":","(String -> msg) -> Sub msg"]
1782 , D.fillSep [D.cyan "port","receive",":","(String -> msg) -> Sub msg"]
@@ -1866,8 +1960,8 @@ typeAliasNote =
1866 [ D.toSimpleNote $
1960 [ D.toSimpleNote $
1867 "Here is an example of a valid `type alias` for reference:"
1961 "Here is an example of a valid `type alias` for reference:"
1868 , D.vcat $
1962 , D.vcat $
1869− [ D.indent 0 $ D.fillSep [D.cyan "type",D.cyan "alias",D.green "Person","="]
1963+ [ D.indent 4 $ D.fillSep [D.cyan "type",D.cyan "alias","Person","="]
1870− , D.indent 2 $ D.vcat $
1964+ , D.indent 6 $ D.vcat $
1871 ["{ name : String"
1965 ["{ name : String"
1872 ,", age : Int"
1966 ,", age : Int"
1873 ,", height : Float"
1967 ,", height : Float"
@@ -2067,10 +2161,10 @@ customTypeNote =
2067 [ D.toSimpleNote $
2161 [ D.toSimpleNote $
2068 "Here is an example of a valid `type` declaration for reference:"
2162 "Here is an example of a valid `type` declaration for reference:"
2069 , D.vcat $
2163 , D.vcat $
2070− [ D.indent 0 $ D.fillSep [D.cyan "type",D.green "Status"]
2164+ [ D.indent 4 $ D.fillSep [D.cyan "type","Status"]
2071− , D.indent 2 $ D.fillSep ["=","Failure"]
2165+ , D.indent 6 $ D.fillSep ["=","Failure"]
2072− , D.indent 2 $ D.fillSep ["|","Waiting"]
2166+ , D.indent 6 $ D.fillSep ["|","Waiting"]
2073− , D.indent 2 $ D.fillSep ["|","Success","String"]
2167+ , D.indent 6 $ D.fillSep ["|","Success","String"]
2075 , D.reflow $
2169 , D.reflow $
2076 "This defines a new `Status` type with three variants. This could be useful if\
2170 "This defines a new `Status` type with three variants. This could be useful if\
@@ -2142,10 +2236,10 @@ toDeclDefReport source name declDef startRow startCol =
2142 ,"a","type","annotation.","It","could","be","something","else","though,","so"
2236 ,"a","type","annotation.","It","could","be","something","else","though,","so"
2143 ,"here","is","a","valid","definition","for","reference:"
2237 ,"here","is","a","valid","definition","for","reference:"
2145− , D.vcat
2239+ , D.indent 4 $ D.vcat $
2146− [ D.fillSep [D.green "add",":","Int","->","Int","->","Int"]
2240+ [ "greet : String -> String"
2147− , D.fillSep [D.green "add","x","y","="]
2241+ , "greet name ="
2148− , D.fillSep [" ","x","+","y"]
2242+ , " " <> D.dullyellow "\"Hello \"" <> " ++ name ++ " <> D.dullyellow "\"!\""
2150 , D.reflow $
2244 , D.reflow $
2151 "Try to use that format with your `" ++ Name.toChars name ++ "` definition!"
2245 "Try to use that format with your `" ++ Name.toChars name ++ "` definition!"
@@ -2167,10 +2261,10 @@ toDeclDefReport source name declDef startRow startCol =
2167 [ D.reflow $
2261 [ D.reflow $
2168 "I am not sure what is going wrong exactly, so here is a valid\
2262 "I am not sure what is going wrong exactly, so here is a valid\
2169 \ definition (with an optional type annotation) for reference:"
2263 \ definition (with an optional type annotation) for reference:"
2170− , D.vcat
2264+ , D.indent 4 $ D.vcat $
2171− [ D.fillSep [D.green "add",":","Int","->","Int","->","Int"]
2265+ [ "greet : String -> String"
2172− , D.fillSep [D.green "add","x","y","="]
2266+ , "greet name ="
2173− , D.fillSep [" ","x","+","y"]
2267+ , " " <> D.dullyellow "\"Hello \"" <> " ++ name ++ " <> D.dullyellow "\"!\""
2175 , D.reflow $
2269 , D.reflow $
2176 "Try to use that format with your `" ++ Name.toChars name ++ "` definition!"
2270 "Try to use that format with your `" ++ Name.toChars name ++ "` definition!"
@@ -2192,10 +2286,10 @@ toDeclDefReport source name declDef startRow startCol =
2192 [ D.reflow $
2286 [ D.reflow $
2193 "I am not sure what is going wrong exactly, so here is a valid\
2287 "I am not sure what is going wrong exactly, so here is a valid\
2194 \ definition (with an optional type annotation) for reference:"
2288 \ definition (with an optional type annotation) for reference:"
2195− , D.vcat
2289+ , D.indent 4 $ D.vcat $
2196− [ D.fillSep [D.green "add",":","Int","->","Int","->","Int"]
2290+ [ "greet : String -> String"
2197− , D.fillSep [D.green "add","x","y","="]
2291+ , "greet name ="
2198− , D.fillSep [" ","x","+","y"]
2292+ , " " <> D.dullyellow "\"Hello \"" <> " ++ name ++ " <> D.dullyellow "\"!\""
2200 , D.reflow $
2294 , D.reflow $
2201 "Try to use that format!"
2295 "Try to use that format!"
@@ -2310,10 +2404,10 @@ declDefNote =
2311 [ D.reflow $
2405 [ D.reflow $
2312 "Here is a valid definition (with a type annotation) for reference:"
2406 "Here is a valid definition (with a type annotation) for reference:"
2313− , D.vcat
2407+ , D.indent 4 $ D.vcat $
2314− [ D.fillSep [D.green "add",":","Int","->","Int","->","Int"]
2408+ [ "greet : String -> String"
2315− , D.fillSep [D.green "add","x","y","="]
2409+ , "greet name ="
2316− , D.fillSep [" ","x","+","y"]
2410+ , " " <> D.dullyellow "\"Hello \"" <> " ++ name ++ " <> D.dullyellow "\"!\""
2318 , D.reflow $
2412 , D.reflow $
2319 "The top line (called a \"type annotation\") is optional. You can leave it off\
2413 "The top line (called a \"type annotation\") is optional. You can leave it off\
@@ -2497,7 +2591,7 @@ toExprReport source context expr startRow startCol =
2497 ,"give","a","more","specific","hint!"
2591 ,"give","a","more","specific","hint!"
2499 , D.toSimpleNote $
2593 , D.toSimpleNote $
2500− "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.\
2501 \ Or if I run into operators in unexpected spots. Point is, there are a\
2595 \ Or if I run into operators in unexpected spots. Point is, there are a\
2502 \ couple ways I can get confused and give sort of weird advice!"
2596 \ couple ways I can get confused and give sort of weird advice!"
@@ -2646,17 +2740,15 @@ toStringReport source string row col =
2646 , D.toSimpleNote $
2740 , D.toSimpleNote $
2647 "For a string that spans multiple lines, you can use the multi-line string\
2741 "For a string that spans multiple lines, you can use the multi-line string\
2648 \ syntax like this:"
2742 \ syntax like this:"
2649− , D.vcat
2743+ , D.dullyellow $ D.indent 4 $ D.vcat $
2650− [ D.fillSep [D.green "markdown","=",D.dullyellow "\"\"\""]
2744+ [ "\"\"\""
2652− , D.dullyellow "# Multi-line Strings"
2745+ , "# Multi-line Strings"
2654− , D.dullyellow "- start with triple double quotes"
2747+ , "- start with triple double quotes"
2655− , D.dullyellow "- write whatever you want"
2748+ , "- write whatever you want"
2656− , D.dullyellow "- no need to escape newlines or double quotes"
2749+ , "- no need to escape newlines or double quotes"
2657− , D.dullyellow "- end with triple double quotes"
2750+ , "- end with triple double quotes"
2659− , D.dullyellow "\"\"\""
2751+ , "\"\"\""
@@ -2675,17 +2767,15 @@ toStringReport source string row col =
2675 [ D.reflow "Add a \"\"\" somewhere after this to end the string."
2767 [ D.reflow "Add a \"\"\" somewhere after this to end the string."
2676 , D.toSimpleNote $
2768 , D.toSimpleNote $
2677 "Here is a valid multi-line string for reference:"
2769 "Here is a valid multi-line string for reference:"
2678− , D.vcat
2770+ , D.dullyellow $ D.indent 4 $ D.vcat $
2679− [ D.fillSep [D.green "markdown","=",D.dullyellow "\"\"\""]
2771+ [ "\"\"\""
2681− , D.dullyellow "# Multi-line Strings"
2772+ , "# Multi-line Strings"
2683− , D.dullyellow "- start with triple double quotes"
2774+ , "- start with triple double quotes"
2684− , D.dullyellow "- write whatever you want"
2775+ , "- write whatever you want"
2685− , D.dullyellow "- no need to escape newlines or double quotes"
2776+ , "- no need to escape newlines or double quotes"
2686− , D.dullyellow "- end with triple double quotes"
2777+ , "- end with triple double quotes"
2688− , D.dullyellow "\"\"\""
2778+ , "\"\"\""
@@ -3150,8 +3240,8 @@ toUnfinishLetReport source row col startRow startCol message =
3150 [ message
3240 [ message
3151 , D.toSimpleNote $
3241 , D.toSimpleNote $
3152 "Here is an example with a valid `let` expression for reference:"
3242 "Here is an example with a valid `let` expression for reference:"
3153− , D.vcat $
3243+ , D.indent 4 $ D.vcat $
3154− [ D.indent 0 $ D.fillSep [D.green "viewPerson","person","="]
3244+ [ D.indent 0 $ D.fillSep ["viewPerson","person","="]
3155 , D.indent 2 $ D.fillSep [D.cyan "let"]
3245 , D.indent 2 $ D.fillSep [D.cyan "let"]
3156 , D.indent 4 $ D.fillSep ["fullName","="]
3246 , D.indent 4 $ D.fillSep ["fullName","="]
3157 , D.indent 6 $ D.fillSep ["person.firstName","++",D.dullyellow "\" \"","++","person.lastName"]
3247 , D.indent 6 $ D.fillSep ["person.firstName","++",D.dullyellow "\" \"","++","person.lastName"]
@@ -3269,10 +3359,10 @@ toLetDefReport source name def startRow startCol =
3269 ,"a","type","annotation.","It","could","be","something","else","though,","so"
3359 ,"a","type","annotation.","It","could","be","something","else","though,","so"
3270 ,"here","is","a","valid","definition","for","reference:"
3360 ,"here","is","a","valid","definition","for","reference:"
3272− , D.vcat
3362+ , D.indent 4 $ D.vcat $
3273− [ D.indent 4 $ D.fillSep [D.green "add",":","Int","->","Int","->","Int"]
3363+ [ "greet : String -> String"
3274− , D.indent 4 $ D.fillSep [D.green "add","x","y","="]
3364+ , "greet name ="
3275− , D.indent 6 $ D.fillSep ["x","+","y"]
3365+ , " " <> D.dullyellow "\"Hello \"" <> " ++ name ++ " <> D.dullyellow "\"!\""
3277 , D.reflow $
3367 , D.reflow $
3278 "Try to use that format with your `" ++ Name.toChars name ++ "` definition!"
3368 "Try to use that format with your `" ++ Name.toChars name ++ "` definition!"
@@ -3294,10 +3384,10 @@ toLetDefReport source name def startRow startCol =
3294 [ D.reflow $
3384 [ D.reflow $
3295 "I am not sure what is going wrong exactly, so here is a valid\
3385 "I am not sure what is going wrong exactly, so here is a valid\
3296 \ definition (with an optional type annotation) for reference:"
3386 \ definition (with an optional type annotation) for reference:"
3297− , D.vcat
3387+ , D.indent 4 $ D.vcat $
3298− [ D.indent 4 $ D.fillSep [D.green "add",":","Int","->","Int","->","Int"]
3388+ [ "greet : String -> String"
3299− , D.indent 4 $ D.fillSep [D.green "add","x","y","="]
3389+ , "greet name ="
3300− , D.indent 6 $ D.fillSep ["x","+","y"]
3390+ , " " <> D.dullyellow "\"Hello \"" <> " ++ name ++ " <> D.dullyellow "\"!\""
3302 , D.reflow $
3392 , D.reflow $
3303 "Try to use that format with your `" ++ Name.toChars name ++ "` definition!"
3393 "Try to use that format with your `" ++ Name.toChars name ++ "` definition!"
@@ -3319,10 +3409,10 @@ toLetDefReport source name def startRow startCol =
3319 [ D.reflow $
3409 [ D.reflow $
3320 "I am not sure what is going wrong exactly, so here is a valid\
3410 "I am not sure what is going wrong exactly, so here is a valid\
3321 \ definition (with an optional type annotation) for reference:"
3411 \ definition (with an optional type annotation) for reference:"
3322− , D.vcat
3412+ , D.indent 4 $ D.vcat $
3323− [ D.indent 4 $ D.fillSep [D.green "add",":","Int","->","Int","->","Int"]
3413+ [ "greet : String -> String"
3324− , D.indent 4 $ D.fillSep [D.green "add","x","y","="]
3414+ , "greet name ="
3325− , D.indent 4 $ D.fillSep ["x","+","y"]
3415+ , " " <> D.dullyellow "\"Hello \"" <> " ++ name ++ " <> D.dullyellow "\"!\""
3327 , D.reflow $
3417 , D.reflow $
3328 "Try to use that format!"
3418 "Try to use that format!"
@@ -3412,10 +3502,10 @@ defNote =
3413 [ D.reflow $
3503 [ D.reflow $
3414 "Here is a valid definition (with a type annotation) for reference:"
3504 "Here is a valid definition (with a type annotation) for reference:"
3415− , D.vcat
3505+ , D.indent 4 $ D.vcat $
3416− [ D.indent 4 $ D.fillSep [D.green "add",":","Int","->","Int","->","Int"]
3506+ [ "greet : String -> String"
3417− , D.indent 4 $ D.fillSep [D.green "add","x","y","="]
3507+ , "greet name ="
3418− , D.indent 6 $ D.fillSep ["x","+","y"]
3508+ , " " <> D.dullyellow "\"Hello \"" <> " ++ name ++ " <> D.dullyellow "\"!\""
3420 , D.reflow $
3510 , D.reflow $
3421 "The top line (called a \"type annotation\") is optional. You can leave it off\
3511 "The top line (called a \"type annotation\") is optional. You can leave it off\
@@ -4056,11 +4146,13 @@ toRecordReport source context record startRow startCol =
4056 D.reflow $
4146 D.reflow $
4057 "I just saw the opening curly brace of a record, but then I got stuck here:"
4147 "I just saw the opening curly brace of a record, but then I got stuck here:"
4059− addNoteForRecordIndentError $
4149+ D.stack
4060− D.fillSep $
4150+ [ D.fillSep $
4061− ["I","am","expecting","a","record","like",D.dullyellow "{ x = 3, y = 4 }","here."
4151+ ["I","am","expecting","a","record","like",D.dullyellow "{ x = 3, y = 4 }","here."
4062− ,"Try","defining","some","fields","of","your","own?"
4152+ ,"Try","defining","some","fields","of","your","own?"
4154+ , noteForRecordIndentError
4066 RecordIndentEnd row col ->
4158 RecordIndentEnd row col ->
@@ -4094,11 +4186,13 @@ toRecordReport source context record startRow startCol =
4094 D.reflow $
4186 D.reflow $
4095 "I was partway through parsing a record, but I got stuck here:"
4187 "I was partway through parsing a record, but I got stuck here:"
4097− addNoteForRecordIndentError $
4189+ D.stack
4098− D.fillSep $
4190+ [ D.fillSep $
4099− ["I","was","expecting","to","see","a","closing","curly","brace","next."
4191+ ["I","was","expecting","to","see","a","closing","curly","brace","next."
4100− ,"Try","putting","a",D.green "}","next","and","see","if","that","helps?"
4192+ ,"Try","putting","a",D.green "}","next","and","see","if","that","helps?"
4194+ , noteForRecordIndentError
4104 RecordIndentField row col ->
4198 RecordIndentField row col ->
@@ -4133,10 +4227,12 @@ toRecordReport source context record startRow startCol =
4133 "I am partway through parsing a record. I just saw a record\
4227 "I am partway through parsing a record. I just saw a record\
4134 \ field, so I was expecting to see an equals sign next:"
4228 \ field, so I was expecting to see an equals sign next:"
4136− addNoteForRecordIndentError $
4230+ D.stack
4137− D.fillSep $
4231+ [ D.fillSep $
4138− ["Try","putting","an",D.green "=","followed","by","an","expression?"
4232+ ["Try","putting","an",D.green "=","followed","by","an","expression?"
4234+ , noteForRecordIndentError
4142 RecordIndentExpr row col ->
4238 RecordIndentExpr row col ->
@@ -4150,11 +4246,13 @@ toRecordReport source context record startRow startCol =
4150 D.reflow $
4246 D.reflow $
4151 "I am partway through parsing a record, and I was expecting to run into an expression next:"
4247 "I am partway through parsing a record, and I was expecting to run into an expression next:"
4153− addNoteForRecordIndentError $
4249+ D.stack
4154− D.fillSep $
4250+ [ D.fillSep $
4155− ["Try","putting","something","like"
4251+ ["Try","putting","something","like"
4156− ,D.dullyellow "42","or",D.dullyellow"\"hello\"","for","now?"
4252+ ,D.dullyellow "42","or",D.dullyellow"\"hello\"","for","now?"
4254+ , noteForRecordIndentError
@@ -4164,9 +4262,9 @@ noteForRecordError =
4164 [ D.toSimpleNote
4262 [ D.toSimpleNote
4165 "If you are trying to define a record across multiple lines, I recommend using this format:"
4263 "If you are trying to define a record across multiple lines, I recommend using this format:"
4166 , D.indent 4 $ D.vcat $
4264 , D.indent 4 $ D.vcat $
4167− [ "{ name = \"Alice\""
4265+ [ "{ name = " <> D.dullyellow "\"Alice\""
4168− , ", age = 42"
4266+ , ", age = " <> D.dullyellow "42"
4169− , ", height = 1.75"
4267+ , ", height = " <> D.dullyellow "1.75"
4172 , D.reflow $
4270 , D.reflow $
@@ -4175,18 +4273,16 @@ noteForRecordError =
4178−addNoteForRecordIndentError :: D.Doc -> D.Doc
4276+noteForRecordIndentError :: D.Doc
4179−addNoteForRecordIndentError normalRecommendation =
4277+noteForRecordIndentError =
4180− D.stack $
4278+ D.stack
4181− normalRecommendation
4183 [ D.toSimpleNote
4279 [ D.toSimpleNote
4184 "I may be confused by indentation. For example, if you are trying to define\
4280 "I may be confused by indentation. For example, if you are trying to define\
4185 \ a record across multiple lines, I recommend using this format:"
4281 \ a record across multiple lines, I recommend using this format:"
4186 , D.indent 4 $ D.vcat $
4282 , D.indent 4 $ D.vcat $
4187− [ "{ name = \"Alice\""
4283+ [ "{ name = " <> D.dullyellow "\"Alice\""
4188− , ", age = 42"
4284+ , ", age = " <> D.dullyellow "42"
4189− , ", height = 1.75"
4285+ , ", height = " <> D.dullyellow "1.75"
4192 , D.reflow $
4288 , D.reflow $
@@ -4380,9 +4476,9 @@ toListReport source context list startRow startCol =
4380 , D.toSimpleNote
4476 , D.toSimpleNote
4381 "I recommend using the following format for lists that span multiple lines:"
4477 "I recommend using the following format for lists that span multiple lines:"
4382 , D.indent 4 $ D.vcat $
4478 , D.indent 4 $ D.vcat $
4383− [ "[ \"Alice\""
4479+ [ "[ " <> D.dullyellow "\"Alice\""
4384− , ", \"Bob\""
4480+ , ", " <> D.dullyellow "\"Bob\""
4385− , ", \"Chuck\""
4481+ , ", " <> D.dullyellow "\"Chuck\""
4388 , D.reflow $
4484 , D.reflow $
@@ -4440,9 +4536,9 @@ toListReport source context list startRow startCol =
4440 "I may be confused by indentation. For example, if you are trying to define\
4536 "I may be confused by indentation. For example, if you are trying to define\
4441 \ a list across multiple lines, I recommend using this format:"
4537 \ a list across multiple lines, I recommend using this format:"
4442 , D.indent 4 $ D.vcat $
4538 , D.indent 4 $ D.vcat $
4443− [ "[ \"Alice\""
4539+ [ "[ " <> D.dullyellow "\"Alice\""
4444− , ", \"Bob\""
4540+ , ", " <> D.dullyellow "\"Bob\""
4445− , ", \"Chuck\""
4541+ , ", " <> D.dullyellow "\"Chuck\""
4448 , D.reflow $
4544 , D.reflow $
@@ -4471,9 +4567,9 @@ toListReport source context list startRow startCol =
4471 "I may be confused by indentation. For example, if you are trying to define\
4567 "I may be confused by indentation. For example, if you are trying to define\
4472 \ a list across multiple lines, I recommend using this format:"
4568 \ a list across multiple lines, I recommend using this format:"
4473 , D.indent 4 $ D.vcat $
4569 , D.indent 4 $ D.vcat $
4474− [ "[ \"Alice\""
4570+ [ "[ " <> D.dullyellow "\"Alice\""
4475− , ", \"Bob\""
4571+ , ", " <> D.dullyellow "\"Bob\""
4476− , ", \"Chuck\""
4572+ , ", " <> D.dullyellow "\"Chuck\""
4479 , D.reflow $
4575 , D.reflow $
@@ -4499,9 +4595,9 @@ toListReport source context list startRow startCol =
4499 , D.toSimpleNote
4595 , D.toSimpleNote
4500 "I recommend using the following format for lists that span multiple lines:"
4596 "I recommend using the following format for lists that span multiple lines:"
4501 , D.indent 4 $ D.vcat $
4597 , D.indent 4 $ D.vcat $
4502− [ "[ \"Alice\""
4598+ [ "[ " <> D.dullyellow "\"Alice\""
4503− , ", \"Bob\""
4599+ , ", " <> D.dullyellow "\"Bob\""
4504− , ", \"Chuck\""
4600+ , ", " <> D.dullyellow "\"Chuck\""
4507 , D.reflow $
4603 , D.reflow $