@@ -69,6 +69,9 @@ data Error
69 | ModuleNameMismatch ModuleName.Raw (A.Located ModuleName.Raw)
69 | ModuleNameMismatch ModuleName.Raw (A.Located ModuleName.Raw)
70 | UnexpectedPort A.Region
70 | UnexpectedPort A.Region
71 | NoPorts A.Region
71 | NoPorts A.Region
72+ | NoPortsInPackage (A.Located Name.Name)
73+ | NoPortModulesInPackage A.Region
74+ | NoEffectsOutsideKernel A.Region
72 | ParseError Module
75 | ParseError Module
@@ -517,7 +520,7 @@ toReport source err =
519 [ D.reflow $
522 [ D.reflow $
520− "I need it to match the file path, so I was expecting it to see `"
523+ "I need it to match the file path, so I was expecting to see `"
521 ++ ModuleName.toChars expectedName
524 ++ ModuleName.toChars expectedName
522 ++ "` here. Make the following change, and you should be all set!"
525 ++ "` here. Make the following change, and you should be all set!"
523 , D.indent 4 $
526 , D.indent 4 $
@@ -561,10 +564,84 @@ toReport source err =
567+ NoPortsInPackage (A.At region _) ->
568+ Report.Report "PACKAGES CANNOT HAVE PORTS" region [] $
569+ Code.toSnippet source region Nothing
572+ "Packages cannot declare any ports, so I am getting stuck here:"
576+ "Remove this port declaration."
577+ , noteForPortsInPackage
581+ NoPortModulesInPackage region ->
582+ Report.Report "PACKAGES CANNOT HAVE PORTS" region [] $
583+ Code.toSnippet source region Nothing
586+ "Packages cannot declare any ports, so I am getting stuck here:"
590+ ["Remove","the",D.cyan "port","keyword","and","I"
591+ ,"should","be","able","to","continue."
593+ , noteForPortsInPackage
597+ NoEffectsOutsideKernel region ->
598+ Report.Report "INVALID EFFECT MODULE" region [] $
599+ Code.toSnippet source region Nothing
602+ "It is not possible to declare an `effect module` outside the @elm organization,\
603+ \ so I am getting stuck here:"
607+ "Switch to a normal module declaration."
609+ "Effect modules are designed to allow certain core functionality to be\
610+ \ defined separately from the compiler. So the @elm organization has access to\
611+ \ this so that certain changes, extensions, and fixes can be introduced without\
612+ \ needing to release new Elm binaries. For example, we want to make it possible\
613+ \ to test effects, but this may require changes to the design of effect modules.\
614+ \ By only having them defined in the @elm organization, that kind of design work\
615+ \ can proceed much more smoothly."
564 ParseError modul ->
619 ParseError modul ->
565 toParseErrorReport source modul
620 toParseErrorReport source modul
623+noteForPortsInPackage :: D.Doc
624+noteForPortsInPackage =
627+ "One of the major goals of the package ecosystem is to be completely written\
628+ \ in Elm. This means when you install an Elm package, you can be sure you are safe\
629+ \ from security issues on install and that you are not going to get any runtime\
630+ \ exceptions coming from your new dependency. This design also sets the ecosystem\
631+ \ up to target other platforms more easily (like mobile phones, WebAssembly, etc.)\
632+ \ since no community code explicitly depends on JavaScript even existing."
634+ "Given that overall goal, allowing ports in packages would lead to some pretty\
635+ \ surprising behavior. If ports were allowed in packages, you could install a\
636+ \ package but not realize that it brings in an indirect dependency that defines a\
637+ \ port. Now you have a program that does not work and the fix is to realize that\
638+ \ some JavaScript needs to be added for a dependency you did not even know about.\
639+ \ That would be extremely frustrating! \"So why not allow the package author to\
640+ \ include the necessary JS code as well?\" Now we are back in conflict with our\
641+ \ overall goal to keep all community packages free from runtime exceptions."
568toParseErrorReport :: Code.Source -> Module -> Report.Report
645toParseErrorReport :: Code.Source -> Module -> Report.Report
569toParseErrorReport source modul =
646toParseErrorReport source modul =
570 case modul of
647 case modul of
@@ -572,64 +649,9 @@ toParseErrorReport source modul =
572 toSpaceReport source space row col
649 toSpaceReport source space row col
574 ModuleBadEnd row col ->
651 ModuleBadEnd row col ->
575− case Code.whatIsNext source row col of
652+ if col == 1
576− Code.Keyword keyword ->
653+ then toDeclStartReport source row col
577− let
654+ else toWeirdEndReport source row col
578− region = toKeywordRegion row col keyword
580− Report.Report "RESERVED WORD" region [] $
581− Code.toSnippet source region Nothing
584− "I got stuck on this reserved word:"
587− "The name `" ++ keyword ++ "` is reserved, so try using a different name?"
592− region = toKeywordRegion row col op
594− Report.Report "UNEXPECTED SYMBOL" region [] $
595− Code.toSnippet source region Nothing
598− "I ran into an unexpected symbol:"
601− "I was not expecting to see a " ++ op ++ " here. Try deleting it? Maybe\
602− \ I can give a better hint from there?"
605− Code.Close term bracket ->
607− region = toRegion row col
609− Report.Report ("UNEXPECTED " ++ map Char.toUpper term) region [] $
610− Code.toSnippet source region Nothing
613− "I ran into an unexpected " ++ term ++ ":"
616− "This " ++ bracket : " does not match up with an earlier open " ++ term ++ ". Try deleting it?"
621− region = toRegion row col
623− Report.Report "SYNTAX PROBLEM" region [] $
624− Code.toSnippet source region Nothing
630− "Whatever I am running into is confusing me a lot! Normally I can give fairly\
631− \ specific hints, but something is really tripping me up this time."
634 ModuleProblem row col ->
656 ModuleProblem row col ->
@@ -775,15 +797,15 @@ toParseErrorReport source modul =
775 [ D.reflow $
797 [ D.reflow $
776 "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\
777 \ file with the following lines:"
799 \ file with the following lines:"
778− , D.vcat
800+ , D.indent 4 $ D.vcat $
779 [ D.fillSep [D.cyan "import","Html"]
801 [ D.fillSep [D.cyan "import","Html"]
781− , D.fillSep [D.green "main","="]
803+ , "main ="
782− , D.indent 2 $ D.fillSep [D.cyan "Html" <> ".text",D.dullyellow "\"Hello!\""]
804+ , " Html.text " <> D.dullyellow "\"Hello!\""
784 , D.reflow $
806 , D.reflow $
785− "You should be able to copy those lines directly into your file. Check out\
807+ "You should be able to copy those lines directly into your file. Check out the\
786− \ some of the examples on https://elm-lang.org for more help getting started!"
808+ \ examples at <https://elm-lang.org/examples> for more help getting started!"
787 , D.toSimpleNote $
809 , D.toSimpleNote $
788 "This can also happen when something is indented too much!"
810 "This can also happen when something is indented too much!"
@@ -808,11 +830,12 @@ toParseErrorReport source modul =
808 , D.indent 4 $ D.vcat $
830 , D.indent 4 $ D.vcat $
809 [ D.fillSep [D.cyan "import","Dict"]
831 [ D.fillSep [D.cyan "import","Dict"]
810 , D.fillSep [D.cyan "import","Maybe"]
832 , D.fillSep [D.cyan "import","Maybe"]
811− , D.fillSep [D.cyan "import","Html.Attributes"]
833+ , D.fillSep [D.cyan "import","Html.Attributes",D.cyan "as","A"]
812− , D.fillSep [D.cyan "import","Json.Decode"]
834+ , D.fillSep [D.cyan "import","Json.Decode",D.cyan "exposing","(..)"]
814 , D.reflow $
836 , D.reflow $
815 "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."
@@ -823,7 +846,7 @@ toParseErrorReport source modul =
824 region = toRegion row col
847 region = toRegion row col
826− Report.Report "EXECTING IMPORT ALIAS" region [] $
849+ Report.Report "EXPECTING IMPORT ALIAS" region [] $
827 Code.toSnippet source region Nothing
850 Code.toSnippet source region Nothing
829 D.reflow $
852 D.reflow $
@@ -839,6 +862,7 @@ toParseErrorReport source modul =
840 , D.reflow $
863 , D.reflow $
841 "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."
@@ -901,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."
904-- IMPORTS
1114-- IMPORTS
@@ -926,6 +1136,7 @@ toImportReport source row col =
927 , D.reflow $
1137 , D.reflow $
928 "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."
@@ -1232,106 +1443,7 @@ toDeclarationsReport :: Code.Source -> Decl -> Report.Report
1232toDeclarationsReport source decl =
1443toDeclarationsReport source decl =
1233 case decl of
1444 case decl of
1234 DeclStart row col ->
1445 DeclStart row col ->
1235− case Code.whatIsNext source row col of
1446+ toDeclStartReport source row col
1236− Code.Close term bracket ->
1238− region = toRegion row col
1240− Report.Report ("STRAY " ++ map Char.toUpper term) region [] $
1241− Code.toSnippet source region Nothing
1244− "I was not expecting to see a " ++ term ++ " here:"
1246− "This " ++ bracket : " does not match up with an earlier open " ++ term ++ ". Try deleting it?"
1249− Code.Keyword keyword ->
1251− region = toKeywordRegion row col keyword
1253− Report.Report "RESERVED WORD" region [] $
1254− Code.toSnippet source region Nothing
1257− "I was not expecting to run into the `" ++ keyword ++ "` keyword here:"
1262− "It is reserved for declaring imports at the top of your module. If you want\
1263− \ another import, try moving it up top with the other imports. If you want to\
1264− \ define a value or function, try changing the name to something else!"
1269− "It is reserved for writing `case` expressions. Try using a different name?"
1271− "If you are trying to write a `case` expression, it needs to be part of a\
1272− \ definition. So you could write something like this instead:"
1274− [ D.indent 0 $ D.fillSep [D.green "getWidth","maybeWidth","="]
1275− , D.indent 2 $ D.fillSep [D.cyan "case","maybeWidth",D.cyan "of"]
1276− , D.indent 4 $ D.fillSep [D.blue "Just","width","->"]
1277− , D.indent 6 $ D.fillSep ["width","+",D.dullyellow "200"]
1279− , D.indent 4 $ D.fillSep [D.blue "Nothing","->"]
1280− , D.indent 6 $ D.fillSep [D.dullyellow "400"]
1283− "This defines a `getWidth` function that we can use elsewhere in our program."
1289− "It is reserved for writing `if` expressions. Try using a different name?"
1291− "If you are trying to write an `if` expression, it needs to be part of a\
1292− \ definition. So you could write something like this instead:"
1294− [ D.indent 0 $ D.fillSep [D.green "reviewPowerLevel","powerLevel","="]
1295− , D.indent 2 $ D.fillSep $
1296− [D.cyan "if","powerLevel",">",D.dullyellow "9000"
1297− ,D.cyan "then",D.dullyellow "\"OVER 9000!!!\""
1298− ,D.cyan "else",D.dullyellow "\"not bad\""
1302− "This defines a `reviewPowerLevel` function that we can use elsewhere in our program."
1307− "It is a reserved word. Try changing the name to something else?"
1312− region = toRegion row col
1314− Report.Report "SYNTAX PROBLEM" region [] $
1315− Code.toSnippet source region Nothing
1318− "I was expecting to see a new declaration here:"
1322− "I am not sure what is going wrong exactly, but here are a couple valid\
1323− \ declarations for reference:"
1325− [ D.fillSep [D.green "add",":","Int","->","Int","->","Int"]
1326− , D.fillSep [D.green "add","x","y","="]
1327− , D.fillSep [" ","x","+","y"]
1329− , D.fillSep [D.cyan "type",D.green "User","=","Anonymous","|","LoggedIn String"]
1331− "Note that all declarations start with lower-case letters in Elm. Capitalization\
1332− \ makes a difference, so be consious of that if you are working from examples!"
1336 DeclSpace space row col ->
1448 DeclSpace space row col ->
1337 toSpaceReport source space row col
1449 toSpaceReport source space row col
@@ -1361,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?"
@@ -1487,7 +1758,7 @@ toPortReport source port_ startRow startCol =
1487 [ D.reflow $
1758 [ D.reflow $
1488 "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\
1489 \ incoming ports for reference:"
1760 \ incoming ports for reference:"
1490− , D.vcat
1761+ , D.indent 4 $ D.vcat $
1491 [ D.fillSep [D.cyan "port","send",":","String -> Cmd msg"]
1762 [ D.fillSep [D.cyan "port","send",":","String -> Cmd msg"]
1492 , D.fillSep [D.cyan "port","receive",":","(String -> msg) -> Sub msg"]
1763 , D.fillSep [D.cyan "port","receive",":","(String -> msg) -> Sub msg"]
@@ -1506,7 +1777,7 @@ portNote =
1507 [ D.toSimpleNote $
1778 [ D.toSimpleNote $
1508 "Here are some example `port` declarations for reference:"
1779 "Here are some example `port` declarations for reference:"
1509− , D.vcat
1780+ , D.indent 4 $ D.vcat $
1510 [ D.fillSep [D.cyan "port","send",":","String -> Cmd msg"]
1781 [ D.fillSep [D.cyan "port","send",":","String -> Cmd msg"]
1511 , D.fillSep [D.cyan "port","receive",":","(String -> msg) -> Sub msg"]
1782 , D.fillSep [D.cyan "port","receive",":","(String -> msg) -> Sub msg"]
@@ -1636,7 +1907,7 @@ toTypeAliasReport source typeAlias startRow startCol =
1638 [ D.reflow $
1909 [ D.reflow $
1639− "I was expecting to see a type variable or an an equals sign next."
1910+ "I was expecting to see a type variable or an equals sign next."
1640 , typeAliasNote
1911 , typeAliasNote
@@ -1657,7 +1928,7 @@ toTypeAliasReport source typeAlias startRow startCol =
1659 [ D.reflow $
1930 [ D.reflow $
1660− "I was expecting to see a type variable or an an equals sign next."
1931+ "I was expecting to see a type variable or an equals sign next."
1661 , typeAliasNote
1932 , typeAliasNote
@@ -1689,8 +1960,8 @@ typeAliasNote =
1689 [ D.toSimpleNote $
1960 [ D.toSimpleNote $
1690 "Here is an example of a valid `type alias` for reference:"
1961 "Here is an example of a valid `type alias` for reference:"
1691 , D.vcat $
1962 , D.vcat $
1692− [ 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","="]
1693− , D.indent 2 $ D.vcat $
1964+ , D.indent 6 $ D.vcat $
1694 ["{ name : String"
1965 ["{ name : String"
1695 ,", age : Int"
1966 ,", age : Int"
1696 ,", height : Float"
1967 ,", height : Float"
@@ -1764,7 +2035,7 @@ toCustomTypeReport source customType startRow startCol =
1766 [ D.reflow $
2037 [ D.reflow $
1767− "I was expecting to see a type variable or an an equals sign next."
2038+ "I was expecting to see a type variable or an equals sign next."
1768 , customTypeNote
2039 , customTypeNote
@@ -1824,7 +2095,7 @@ toCustomTypeReport source customType startRow startCol =
1826 [ D.reflow $
2097 [ D.reflow $
1827− "I was expecting to see a type variable or an an equals sign next."
2098+ "I was expecting to see a type variable or an equals sign next."
1828 , customTypeNote
2099 , customTypeNote
@@ -1890,10 +2161,10 @@ customTypeNote =
1890 [ D.toSimpleNote $
2161 [ D.toSimpleNote $
1891 "Here is an example of a valid `type` declaration for reference:"
2162 "Here is an example of a valid `type` declaration for reference:"
1892 , D.vcat $
2163 , D.vcat $
1893− [ D.indent 0 $ D.fillSep [D.cyan "type",D.green "Status"]
2164+ [ D.indent 4 $ D.fillSep [D.cyan "type","Status"]
1894− , D.indent 2 $ D.fillSep ["=","Failure"]
2165+ , D.indent 6 $ D.fillSep ["=","Failure"]
1895− , D.indent 2 $ D.fillSep ["|","Waiting"]
2166+ , D.indent 6 $ D.fillSep ["|","Waiting"]
1896− , D.indent 2 $ D.fillSep ["|","Success","String"]
2167+ , D.indent 6 $ D.fillSep ["|","Success","String"]
1898 , D.reflow $
2169 , D.reflow $
1899 "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\
@@ -1924,11 +2195,55 @@ toDeclDefReport source name declDef startRow startCol =
1924 Report.Report "RESERVED WORD" region [] $
2195 Report.Report "RESERVED WORD" region [] $
1925 Code.toSnippet source surroundings (Just region)
2196 Code.toSnippet source surroundings (Just region)
1927− D.reflow $
2198+ D.fillSep
1928− "It looks like you are trying to use `" ++ keyword ++ "` as an argument:"
2199+ ["The","name"
2200+ ,"`" <> D.cyan (D.fromChars keyword) <> "`"
2201+ ,"is","reserved","in","Elm,","so","it","cannot"
2202+ ,"be","used","as","an","argument","here:"
2207+ "Try renaming it to something else."
2211+ ["This","keyword","is","reserved","for","pattern","matches","like"
2212+ ,"((x,y)",D.cyan "as","point)","where","you","want","to","name","a","tuple","and"
2213+ ,"the","values","it","contains."
2218+ "The `" ++ keyword ++ "` keyword has a special meaning in Elm, so it can only be used in certain situations."
2222+ Code.Operator "->" ->
2224+ surroundings = A.Region (A.Position startRow startCol) (A.Position row col)
2225+ region = toWiderRegion row col 2
2227+ Report.Report "MISSING COLON?" region [] $
2228+ Code.toSnippet source surroundings (Just region)
1930 D.reflow $
2230 D.reflow $
1931− "This is a reserved word! Try using some other name?"
2231+ "I was not expecting to see an arrow here:"
2235+ ["This","usually","means","a",D.green ":","is","missing","a","bit","earlier","in"
2236+ ,"a","type","annotation.","It","could","be","something","else","though,","so"
2237+ ,"here","is","a","valid","definition","for","reference:"
2239+ , D.indent 4 $ D.vcat $
2240+ [ "greet : String -> String"
2242+ , " " <> D.dullyellow "\"Hello \"" <> " ++ name ++ " <> D.dullyellow "\"!\""
2245+ "Try to use that format with your `" ++ Name.toChars name ++ "` definition!"
1934 Code.Operator op ->
2249 Code.Operator op ->
@@ -1946,10 +2261,10 @@ toDeclDefReport source name declDef startRow startCol =
1946 [ D.reflow $
2261 [ D.reflow $
1947 "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\
1948 \ definition (with an optional type annotation) for reference:"
2263 \ definition (with an optional type annotation) for reference:"
1949− , D.vcat
2264+ , D.indent 4 $ D.vcat $
1950− [ D.fillSep [D.green "add",":","Int","->","Int","->","Int"]
2265+ [ "greet : String -> String"
1951− , D.fillSep [D.green "add","x","y","="]
2266+ , "greet name ="
1952− , D.fillSep [" ","x","+","y"]
2267+ , " " <> D.dullyellow "\"Hello \"" <> " ++ name ++ " <> D.dullyellow "\"!\""
1954 , D.reflow $
2269 , D.reflow $
1955 "Try to use that format with your `" ++ Name.toChars name ++ "` definition!"
2270 "Try to use that format with your `" ++ Name.toChars name ++ "` definition!"
@@ -1971,10 +2286,10 @@ toDeclDefReport source name declDef startRow startCol =
1971 [ D.reflow $
2286 [ D.reflow $
1972 "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\
1973 \ definition (with an optional type annotation) for reference:"
2288 \ definition (with an optional type annotation) for reference:"
1974− , D.vcat
2289+ , D.indent 4 $ D.vcat $
1975− [ D.fillSep [D.green "add",":","Int","->","Int","->","Int"]
2290+ [ "greet : String -> String"
1976− , D.fillSep [D.green "add","x","y","="]
2291+ , "greet name ="
1977− , D.fillSep [" ","x","+","y"]
2292+ , " " <> D.dullyellow "\"Hello \"" <> " ++ name ++ " <> D.dullyellow "\"!\""
1979 , D.reflow $
2294 , D.reflow $
1980 "Try to use that format!"
2295 "Try to use that format!"
@@ -2089,10 +2404,10 @@ declDefNote =
2090 [ D.reflow $
2405 [ D.reflow $
2091 "Here is a valid definition (with a type annotation) for reference:"
2406 "Here is a valid definition (with a type annotation) for reference:"
2092− , D.vcat
2407+ , D.indent 4 $ D.vcat $
2093− [ D.fillSep [D.green "add",":","Int","->","Int","->","Int"]
2408+ [ "greet : String -> String"
2094− , D.fillSep [D.green "add","x","y","="]
2409+ , "greet name ="
2095− , D.fillSep [" ","x","+","y"]
2410+ , " " <> D.dullyellow "\"Hello \"" <> " ++ name ++ " <> D.dullyellow "\"!\""
2097 , D.reflow $
2412 , D.reflow $
2098 "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\
@@ -2204,25 +2519,40 @@ toExprReport source context expr startRow startCol =
2206 OperatorRight op row col ->
2521 OperatorRight op row col ->
2523+ surroundings = A.Region (A.Position startRow startCol) (A.Position row col)
2207− let region = toRegion row col in
2524+ region = toRegion row col
2525+ isMath = elem op ["-","+","*","/","^"]
2208 Report.Report "MISSING EXPRESSION" region [] $
2527 Report.Report "MISSING EXPRESSION" region [] $
2209− Code.toSnippet source region Nothing
2528+ Code.toSnippet source surroundings (Just region)
2211 D.reflow $
2530 D.reflow $
2212− "I was expecting to see an expression after this " ++ Name.toChars op ++ " operator:"
2531+ "I just saw a " ++ Name.toChars op ++ " "
2532+ ++ (if isMath then "sign" else "operator")
2533+ ++ ", so I am getting stuck here:"
2214− D.stack
2535+ if isMath then
2215− [ D.fillSep $
2536+ D.fillSep
2216− ["You","can","just","put","anything","for","now,","like"
2537+ ["I","was","expecting","to","see","an","expression","next."
2217− ,D.dullyellow "42","or",D.dullyellow"\"hello\"" <> "."
2538+ ,"Something","like",D.dullyellow "42","or",D.dullyellow "1000"
2218− ,"Once","there","is","something","there,","I","can","probably"
2539+ ,"that","makes","sense","with","a",D.fromName op,"sign."
2219− ,"give","a","more","specific","hint!"
2540+ ]
2541+ else if op == "&&" || op == "||" then
2543+ ["I","was","expecting","to","see","an","expression","next."
2544+ ,"Something","like",D.dullyellow "True","or",D.dullyellow "False"
2545+ ,"that","makes","sense","with","boolean","logic."
2221− , D.toSimpleNote $
2547+ else if op == "|>" then
2222− "This can also happen if run into reserved words like `let` or `as` unexpectedly.\
2548+ D.reflow $
2223− \ Or if I run into operators in unexpected spots. Point is, there are a\
2549+ "I was expecting to see a function next."
2224− \ couple ways I can get confused and give sort of weird advice!"
2550+ else if op == "<|" then
2552+ "I was expecting to see an argument next."
2555+ "I was expecting to see an expression next."
2228 OperatorReserved operator row col ->
2558 OperatorReserved operator row col ->
@@ -2261,7 +2591,7 @@ toExprReport source context expr startRow startCol =
2261 ,"give","a","more","specific","hint!"
2591 ,"give","a","more","specific","hint!"
2263 , D.toSimpleNote $
2593 , D.toSimpleNote $
2264− "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.\
2265 \ 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\
2266 \ 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!"
@@ -2410,17 +2740,15 @@ toStringReport source string row col =
2410 , D.toSimpleNote $
2740 , D.toSimpleNote $
2411 "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\
2412 \ syntax like this:"
2742 \ syntax like this:"
2413− , D.vcat
2743+ , D.dullyellow $ D.indent 4 $ D.vcat $
2414− [ D.fillSep [D.green "markdown","=",D.dullyellow "\"\"\""]
2744+ [ "\"\"\""
2416− , D.dullyellow "# Multi-line Strings"
2745+ , "# Multi-line Strings"
2418− , D.dullyellow "- start with triple double quotes"
2747+ , "- start with triple double quotes"
2419− , D.dullyellow "- write whatever you want"
2748+ , "- write whatever you want"
2420− , D.dullyellow "- no need to escape newlines or double quotes"
2749+ , "- no need to escape newlines or double quotes"
2421− , D.dullyellow "- end with triple double quotes"
2750+ , "- end with triple double quotes"
2423− , D.dullyellow "\"\"\""
2751+ , "\"\"\""
@@ -2439,17 +2767,15 @@ toStringReport source string row col =
2439 [ D.reflow "Add a \"\"\" somewhere after this to end the string."
2767 [ D.reflow "Add a \"\"\" somewhere after this to end the string."
2440 , D.toSimpleNote $
2768 , D.toSimpleNote $
2441 "Here is a valid multi-line string for reference:"
2769 "Here is a valid multi-line string for reference:"
2442− , D.vcat
2770+ , D.dullyellow $ D.indent 4 $ D.vcat $
2443− [ D.fillSep [D.green "markdown","=",D.dullyellow "\"\"\""]
2771+ [ "\"\"\""
2445− , D.dullyellow "# Multi-line Strings"
2772+ , "# Multi-line Strings"
2447− , D.dullyellow "- start with triple double quotes"
2774+ , "- start with triple double quotes"
2448− , D.dullyellow "- write whatever you want"
2775+ , "- write whatever you want"
2449− , D.dullyellow "- no need to escape newlines or double quotes"
2776+ , "- no need to escape newlines or double quotes"
2450− , D.dullyellow "- end with triple double quotes"
2777+ , "- end with triple double quotes"
2452− , D.dullyellow "\"\"\""
2778+ , "\"\"\""
@@ -2701,7 +3027,7 @@ toOperatorReport source context operator row col =
2703 [ D.reflow $
3029 [ D.reflow $
2704− "It makes sense to see arrows around here, so I suspect it is something earlier."
3030+ "It makes sense to see arrows around here, so I suspect it is something earlier. Maybe this pattern is indented a bit farther than the previous patterns?"
2705 , noteForCaseIndentError
3031 , noteForCaseIndentError
@@ -2709,11 +3035,15 @@ toOperatorReport source context operator row col =
2711 D.reflow $
3037 D.reflow $
2712− "I was not expecting an arrow here:"
3038+ "I was partway through parsing an expression when I got stuck on this arrow:"
2714− D.reflow $
3040+ D.stack
2715− "Arrows should only appear in `case` expressions and anonymous functions. Maybe\
3041+ [ "Arrows should only appear in `case` expressions and anonymous functions.\n\
2716− \ you want > or >= instead?"
3042+ \Maybe it was supposed to be a > sign instead?"
3044+ "The syntax for anonymous functions is (\\x -> x + 1) so the arguments all appear\
3045+ \ after the backslash and before the arrow. Maybe a backslash is missing earlier?"
2719 BadEquals ->
3049 BadEquals ->
@@ -2840,7 +3170,7 @@ toLetReport source context let_ startRow startCol =
2840 , D.toSimpleNote $
3170 , D.toSimpleNote $
2841 "This can also happen if you are trying to define another value within the `let` but\
3171 "This can also happen if you are trying to define another value within the `let` but\
2842 \ it is not indented enough. Make sure each definition has exactly the same amount of\
3172 \ it is not indented enough. Make sure each definition has exactly the same amount of\
2843− \ spaces before it. The should line up exactly!"
3173+ \ spaces before it. They should line up exactly!"
@@ -2910,8 +3240,8 @@ toUnfinishLetReport source row col startRow startCol message =
2910 [ message
3240 [ message
2911 , D.toSimpleNote $
3241 , D.toSimpleNote $
2912 "Here is an example with a valid `let` expression for reference:"
3242 "Here is an example with a valid `let` expression for reference:"
2913− , D.vcat $
3243+ , D.indent 4 $ D.vcat $
2914− [ D.indent 0 $ D.fillSep [D.green "viewPerson","person","="]
3244+ [ D.indent 0 $ D.fillSep ["viewPerson","person","="]
2915 , D.indent 2 $ D.fillSep [D.cyan "let"]
3245 , D.indent 2 $ D.fillSep [D.cyan "let"]
2916 , D.indent 4 $ D.fillSep ["fullName","="]
3246 , D.indent 4 $ D.fillSep ["fullName","="]
2917 , D.indent 6 $ D.fillSep ["person.firstName","++",D.dullyellow "\" \"","++","person.lastName"]
3247 , D.indent 6 $ D.fillSep ["person.firstName","++",D.dullyellow "\" \"","++","person.lastName"]
@@ -2986,13 +3316,57 @@ toLetDefReport source name def startRow startCol =
2986 region = toKeywordRegion row col keyword
3316 region = toKeywordRegion row col keyword
2988 Report.Report "RESERVED WORD" region [] $
3318 Report.Report "RESERVED WORD" region [] $
3319+ Code.toSnippet source surroundings (Just region)
3323+ ,"`" <> D.cyan (D.fromChars keyword) <> "`"
3324+ ,"is","reserved","in","Elm,","so","it","cannot"
3325+ ,"be","used","as","an","argument","here:"
3330+ "Try renaming it to something else."
3334+ ["This","keyword","is","reserved","for","pattern","matches","like"
3335+ ,"((x,y)",D.cyan "as","point)","where","you","want","to","name","a","tuple","and"
3336+ ,"the","values","it","contains."
3341+ "The `" ++ keyword ++ "` keyword has a special meaning in Elm, so it can only be used in certain situations."
3345+ Code.Operator "->" ->
3347+ surroundings = A.Region (A.Position startRow startCol) (A.Position row col)
3348+ region = toWiderRegion row col 2
3350+ Report.Report "MISSING COLON?" region [] $
2989 Code.toSnippet source surroundings (Just region)
3351 Code.toSnippet source surroundings (Just region)
2991 D.reflow $
3353 D.reflow $
2992− "It looks like you are trying to use `" ++ keyword ++ "` as an argument:"
3354+ "I was not expecting to see an arrow here:"
3358+ ["This","usually","means","a",D.green ":","is","missing","a","bit","earlier","in"
3359+ ,"a","type","annotation.","It","could","be","something","else","though,","so"
3360+ ,"here","is","a","valid","definition","for","reference:"
3362+ , D.indent 4 $ D.vcat $
3363+ [ "greet : String -> String"
3365+ , " " <> D.dullyellow "\"Hello \"" <> " ++ name ++ " <> D.dullyellow "\"!\""
2994− D.reflow $
3367+ , D.reflow $
2995− "This is a reserved word! Try using some other name?"
3368+ "Try to use that format with your `" ++ Name.toChars name ++ "` definition!"
2998 Code.Operator op ->
3372 Code.Operator op ->
@@ -3010,10 +3384,10 @@ toLetDefReport source name def startRow startCol =
3010 [ D.reflow $
3384 [ D.reflow $
3011 "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\
3012 \ definition (with an optional type annotation) for reference:"
3386 \ definition (with an optional type annotation) for reference:"
3013− , D.vcat
3387+ , D.indent 4 $ D.vcat $
3014− [ D.indent 4 $ D.fillSep [D.green "add",":","Int","->","Int","->","Int"]
3388+ [ "greet : String -> String"
3015− , D.indent 4 $ D.fillSep [D.green "add","x","y","="]
3389+ , "greet name ="
3016− , D.indent 6 $ D.fillSep ["x","+","y"]
3390+ , " " <> D.dullyellow "\"Hello \"" <> " ++ name ++ " <> D.dullyellow "\"!\""
3018 , D.reflow $
3392 , D.reflow $
3019 "Try to use that format with your `" ++ Name.toChars name ++ "` definition!"
3393 "Try to use that format with your `" ++ Name.toChars name ++ "` definition!"
@@ -3035,10 +3409,10 @@ toLetDefReport source name def startRow startCol =
3035 [ D.reflow $
3409 [ D.reflow $
3036 "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\
3037 \ definition (with an optional type annotation) for reference:"
3411 \ definition (with an optional type annotation) for reference:"
3038− , D.vcat
3412+ , D.indent 4 $ D.vcat $
3039− [ D.indent 4 $ D.fillSep [D.green "add",":","Int","->","Int","->","Int"]
3413+ [ "greet : String -> String"
3040− , D.indent 4 $ D.fillSep [D.green "add","x","y","="]
3414+ , "greet name ="
3041− , D.indent 4 $ D.fillSep ["x","+","y"]
3415+ , " " <> D.dullyellow "\"Hello \"" <> " ++ name ++ " <> D.dullyellow "\"!\""
3043 , D.reflow $
3417 , D.reflow $
3044 "Try to use that format!"
3418 "Try to use that format!"
@@ -3128,10 +3502,10 @@ defNote =
3129 [ D.reflow $
3503 [ D.reflow $
3130 "Here is a valid definition (with a type annotation) for reference:"
3504 "Here is a valid definition (with a type annotation) for reference:"
3131− , D.vcat
3505+ , D.indent 4 $ D.vcat $
3132− [ D.indent 4 $ D.fillSep [D.green "add",":","Int","->","Int","->","Int"]
3506+ [ "greet : String -> String"
3133− , D.indent 4 $ D.fillSep [D.green "add","x","y","="]
3507+ , "greet name ="
3134− , D.indent 6 $ D.fillSep ["x","+","y"]
3508+ , " " <> D.dullyellow "\"Hello \"" <> " ++ name ++ " <> D.dullyellow "\"!\""
3136 , D.reflow $
3510 , D.reflow $
3137 "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\
@@ -3390,8 +3764,9 @@ noteForCaseIndentError =
3390 , D.indent 8 $ D.fillSep [D.dullyellow "400"]
3764 , D.indent 8 $ D.fillSep [D.dullyellow "400"]
3392 , D.reflow $
3766 , D.reflow $
3393− "Notice the indentation! Each pattern is aligned, and each branch is indented\
3767+ "Notice the indentation! Patterns are aligned with each other. Same indentation.\
3768+ \ The expressions after each arrow are all indented a bit more than the patterns.\
3394− \ a bit more than the corresponding pattern. That is important!"
3769+ \ That is important!"
@@ -3543,23 +3918,43 @@ toIfReport source context if_ startRow startCol =
3545 IfIndentElse row col ->
3920 IfIndentElse row col ->
3921+ case Code.nextLineStartsWithKeyword "else" source row of
3922+ Just (elseRow, elseCol) ->
3924+ surroundings = A.Region (A.Position startRow startCol) (A.Position elseRow elseCol)
3925+ region = toWiderRegion elseRow elseCol 4
3927+ Report.Report "WEIRD ELSE BRANCH" region [] $
3928+ Code.toSnippet source surroundings (Just region)
3931+ "I was partway through an `if` expression when I got stuck here:"
3934+ ["I","think","this",D.cyan "else","keyword","needs","to","be","indented","more."
3935+ ,"Try","adding","some","spaces","before","it."
3547− surroundings = A.Region (A.Position startRow startCol) (A.Position row col)
3941+ surroundings = A.Region (A.Position startRow startCol) (A.Position row col)
3548− region = toRegion row col
3942+ region = toRegion row col
3550− Report.Report "UNFINISHED IF" region [] $
3944+ Report.Report "UNFINISHED IF" region [] $
3551− Code.toSnippet source surroundings (Just region)
3945+ Code.toSnippet source surroundings (Just region)
3553− D.reflow $
3947+ D.reflow $
3554− "I was expecting to see an `else` branch after this:"
3948+ "I was expecting to see an `else` branch after this:"
3556− D.stack
3950+ D.stack
3557− [ D.reflow $
3951+ [ D.fillSep
3558− "I know what to do when the condition is `True`, but not when it is `False`."
3952+ ["I","know","what","to","do","when","the","condition","is","True,"
3559− , D.fillSep
3953+ ,"but","what","happens","when","it","is","False?"
3560− ["Add","an",D.cyan "else","branch","to","handle","that","scenario!"]
3954+ ,"Add","an",D.cyan "else","branch","to","handle","that","scenario!"
@@ -3592,15 +3987,22 @@ toRecordReport source context record startRow startCol =
3592 surroundings = A.Region (A.Position startRow startCol) (A.Position row col)
3987 surroundings = A.Region (A.Position startRow startCol) (A.Position row col)
3593 region = toRegion row col
3988 region = toRegion row col
3595− Report.Report "UNFINISHED RECORD" region [] $
3990+ Report.Report "PROBLEM IN RECORD" region [] $
3596 Code.toSnippet source surroundings (Just region)
3991 Code.toSnippet source surroundings (Just region)
3598 D.reflow $
3993 D.reflow $
3599 "I just started parsing a record, but I got stuck here:"
3994 "I just started parsing a record, but I got stuck here:"
3601− D.fillSep
3997+ [ D.fillSep
3602− ["Records","look","like",D.dullyellow "{ x = 3, y = 4 },"
3603− ,"so","I","was","expecting","to","see","a","field","name","next."
3998+ ["I","was","expecting","to","see","a","record","field","defined","next,"
3999+ ,"so","I","am","looking","for","a","name","like"
4000+ ,D.dullyellow "userName","or",D.dullyellow "plantHeight" <> "."
4003+ "Field names must start with a lower-case letter. After that, you can use\
4004+ \ any sequence of letters, numbers, and underscores."
4005+ , noteForRecordError
@@ -3609,7 +4011,7 @@ toRecordReport source context record startRow startCol =
3609 surroundings = A.Region (A.Position startRow startCol) (A.Position row col)
4011 surroundings = A.Region (A.Position startRow startCol) (A.Position row col)
3610 region = toRegion row col
4012 region = toRegion row col
3612− Report.Report "UNFINISHED RECORD" region [] $
4014+ Report.Report "PROBLEM IN RECORD" region [] $
3613 Code.toSnippet source surroundings (Just region)
4015 Code.toSnippet source surroundings (Just region)
3615 D.reflow $
4017 D.reflow $
@@ -3644,22 +4046,67 @@ toRecordReport source context record startRow startCol =
3644 \ that is a reserved word. Try using a different name!"
4046 \ that is a reserved word. Try using a different name!"
4049+ Code.Other (Just ',') ->
4051+ surroundings = A.Region (A.Position startRow startCol) (A.Position row col)
4052+ region = toRegion row col
4054+ Report.Report "EXTRA COMMA" region [] $
4055+ Code.toSnippet source surroundings (Just region)
4058+ "I am partway through parsing a record, but I got stuck here:"
4062+ "I am seeing two commas in a row. This is the second one!"
4064+ "Just delete one of the commas and you should be all set!"
4065+ , noteForRecordError
4069+ Code.Close _ '}' ->
4071+ surroundings = A.Region (A.Position startRow startCol) (A.Position row col)
4072+ region = toRegion row col
4074+ Report.Report "EXTRA COMMA" region [] $
4075+ Code.toSnippet source surroundings (Just region)
4078+ "I am partway through parsing a record, but I got stuck here:"
4082+ "Trailing commas are not allowed in records. Try deleting the comma that appears\
4083+ \ before this closing curly brace."
4084+ , noteForRecordError
3649 surroundings = A.Region (A.Position startRow startCol) (A.Position row col)
4090 surroundings = A.Region (A.Position startRow startCol) (A.Position row col)
3650 region = toRegion row col
4091 region = toRegion row col
3652− Report.Report "UNFINISHED RECORD" region [] $
4093+ Report.Report "PROBLEM IN RECORD" region [] $
3653 Code.toSnippet source surroundings (Just region)
4094 Code.toSnippet source surroundings (Just region)
3655 D.reflow $
4096 D.reflow $
3656− "I am partway through parsing a record, but I got stuck after that last comma:"
4097+ "I am partway through parsing a record, but I got stuck here:"
3658− addNoteForRecordError $
4099+ D.stack
3659− D.reflow $
4100+ [ D.fillSep
3660− "Trailing commas are not allowed in records, so I was expecting to see another\
4101+ ["I","was","expecting","to","see","another","record","field","defined","next,"
3661− \ record field defined next. If you are done defining the record, the fix may\
4102+ ,"so","I","am","looking","for","a","name","like"
3662− \ be to delete that last comma?"
4103+ ,D.dullyellow "userName","or",D.dullyellow "plantHeight" <> "."
4106+ "Field names must start with a lower-case letter. After that, you can use\
4107+ \ any sequence of letters, numbers, and underscores."
4108+ , noteForRecordError
3665 RecordEquals row col ->
4112 RecordEquals row col ->
@@ -3667,17 +4114,19 @@ toRecordReport source context record startRow startCol =
3667 surroundings = A.Region (A.Position startRow startCol) (A.Position row col)
4114 surroundings = A.Region (A.Position startRow startCol) (A.Position row col)
3668 region = toRegion row col
4115 region = toRegion row col
3670− Report.Report "UNFINISHED RECORD" region [] $
4117+ Report.Report "PROBLEM IN RECORD" region [] $
3671 Code.toSnippet source surroundings (Just region)
4118 Code.toSnippet source surroundings (Just region)
3673 D.reflow $
4120 D.reflow $
3674 "I am partway through parsing a record, but I got stuck here:"
4121 "I am partway through parsing a record, but I got stuck here:"
3676− addNoteForRecordError $
4123+ D.stack
3677− D.fillSep $
4124+ [ D.fillSep $
3678− ["I","just","saw","a","field","name,","so","I","was","expecting","to","see"
4125+ ["I","just","saw","a","field","name,","so","I","was","expecting","to","see"
3679− ,"an","equals","sign","next.","So","try","putting","an",D.green "=","sign","here?"
4126+ ,"an","equals","sign","next.","So","try","putting","an",D.green "=","sign","here?"
4128+ , noteForRecordError
3683 RecordExpr expr row col ->
4132 RecordExpr expr row col ->
@@ -3697,29 +4146,54 @@ toRecordReport source context record startRow startCol =
3697 D.reflow $
4146 D.reflow $
3698 "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:"
3700− addNoteForRecordIndentError $
4149+ D.stack
3701− D.fillSep $
4150+ [ D.fillSep $
3702− ["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."
3703− ,"Try","defining","some","fields","of","your","own?"
4152+ ,"Try","defining","some","fields","of","your","own?"
4154+ , noteForRecordIndentError
3707 RecordIndentEnd row col ->
4158 RecordIndentEnd row col ->
4159+ case Code.nextLineStartsWithCloseCurly source row of
4160+ Just (curlyRow, curlyCol) ->
4162+ surroundings = A.Region (A.Position startRow startCol) (A.Position curlyRow curlyCol)
4163+ region = toRegion curlyRow curlyCol
4165+ Report.Report "NEED MORE INDENTATION" region [] $
4166+ Code.toSnippet source surroundings (Just region)
4169+ "I was partway through parsing a record, but I got stuck here:"
4173+ "I need this curly brace to be indented more. Try adding some spaces before it!"
4174+ , noteForRecordError
3709− surroundings = A.Region (A.Position startRow startCol) (A.Position row col)
4180+ surroundings = A.Region (A.Position startRow startCol) (A.Position row col)
3710− region = toRegion row col
4181+ region = toRegion row col
3712− Report.Report "UNFINISHED RECORD" region [] $
4183+ Report.Report "UNFINISHED RECORD" region [] $
3713− Code.toSnippet source surroundings (Just region)
4184+ Code.toSnippet source surroundings (Just region)
3715− D.reflow $
4186+ D.reflow $
4187+ "I was partway through parsing a record, but I got stuck here:"
3716− "I was expecting to see a closing curly brace next:"
4191+ ["I","was","expecting","to","see","a","closing","curly","brace","next."
3718− addNoteForRecordIndentError $
3720− ["Try","putting","an",D.green "}","and","see","if","that","helps?"
4192+ ,"Try","putting","a",D.green "}","next","and","see","if","that","helps?"
4194+ , noteForRecordIndentError
3724 RecordIndentField row col ->
4198 RecordIndentField row col ->
@@ -3732,11 +4206,13 @@ toRecordReport source context record startRow startCol =
3732 D.reflow $
4206 D.reflow $
3733 "I am partway through parsing a record, but I got stuck after that last comma:"
4207 "I am partway through parsing a record, but I got stuck after that last comma:"
3735− addNoteForRecordError $
4209+ D.stack
3736− D.reflow $
4210+ [ D.reflow $
3737− "Trailing commas are not allowed in records, so the fix may be to\
4211+ "Trailing commas are not allowed in records, so the fix may be to\
3738− \ delete that last comma? Or maybe you were in the middle of defining\
4212+ \ delete that last comma? Or maybe you were in the middle of defining\
3739− \ an additional field?"
4213+ \ an additional field?"
4214+ , noteForRecordError
3742 RecordIndentEquals row col ->
4218 RecordIndentEquals row col ->
@@ -3751,10 +4227,12 @@ toRecordReport source context record startRow startCol =
3751 "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\
3752 \ field, so I was expecting to see an equals sign next:"
4228 \ field, so I was expecting to see an equals sign next:"
3754− addNoteForRecordIndentError $
4230+ D.stack
3755− D.fillSep $
4231+ [ D.fillSep $
3756− ["Try","putting","an",D.green "=","followed","by","an","expression?"
4232+ ["Try","putting","an",D.green "=","followed","by","an","expression?"
4234+ , noteForRecordIndentError
3760 RecordIndentExpr row col ->
4238 RecordIndentExpr row col ->
@@ -3768,52 +4246,48 @@ toRecordReport source context record startRow startCol =
3768 D.reflow $
4246 D.reflow $
3769 "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:"
3771− addNoteForRecordIndentError $
4249+ D.stack
3772− D.fillSep $
4250+ [ D.fillSep $
3773− ["Try","putting","something","like"
4251+ ["Try","putting","something","like"
3774− ,D.dullyellow "42","or",D.dullyellow"\"hello\"","for","now?"
4252+ ,D.dullyellow "42","or",D.dullyellow"\"hello\"","for","now?"
4254+ , noteForRecordIndentError
3779−addNoteForRecordError :: D.Doc -> D.Doc
4259+noteForRecordError :: D.Doc
3780−addNoteForRecordError normalRecommendation =
4260+noteForRecordError =
3781 D.stack $
4261 D.stack $
3782− normalRecommendation
3784 [ D.toSimpleNote
4262 [ D.toSimpleNote
3785 "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:"
3786 , D.indent 4 $ D.vcat $
4264 , D.indent 4 $ D.vcat $
3787− [ "{ name = \"Alice\""
4265+ [ "{ name = " <> D.dullyellow "\"Alice\""
3788− , ", age = 42"
4266+ , ", age = " <> D.dullyellow "42"
3789− , ", height = 1.75"
4267+ , ", height = " <> D.dullyellow "1.75"
3792 , D.reflow $
4270 , D.reflow $
3793− "Notice that each line starts with some indentation. Usually two or four spaces. I\
4271+ "Notice that each line starts with some indentation. Usually two or four spaces.\
3794− \ know this style can be jarring for people coming from C-like syntax, but folks generally\
4272+ \ This is the stylistic convention in the Elm ecosystem."
3795− \ report that they are used to it (and often prefer it!) after a week or two of using Elm."
3799−addNoteForRecordIndentError :: D.Doc -> D.Doc
4276+noteForRecordIndentError :: D.Doc
3800−addNoteForRecordIndentError normalRecommendation =
4277+noteForRecordIndentError =
3801− D.stack $
4278+ D.stack
3802− normalRecommendation
3804 [ D.toSimpleNote
4279 [ D.toSimpleNote
3805 "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\
3806 \ a record across multiple lines, I recommend using this format:"
4281 \ a record across multiple lines, I recommend using this format:"
3807 , D.indent 4 $ D.vcat $
4282 , D.indent 4 $ D.vcat $
3808− [ "{ name = \"Alice\""
4283+ [ "{ name = " <> D.dullyellow "\"Alice\""
3809− , ", age = 42"
4284+ , ", age = " <> D.dullyellow "42"
3810− , ", height = 1.75"
4285+ , ", height = " <> D.dullyellow "1.75"
3813 , D.reflow $
4288 , D.reflow $
3814− "Notice that each line starts with some indentation. Usually two or four spaces. I\
4289+ "Notice that each line starts with some indentation. Usually two or four spaces.\
3815− \ know this style can be jarring for people coming from C-like syntax, but folks generally\
4290+ \ This is the stylistic convention in the Elm ecosystem!"
3816− \ report that they are used to it (and often prefer it!) after a week or two of using Elm."
@@ -4002,15 +4476,14 @@ toListReport source context list startRow startCol =
4002 , D.toSimpleNote
4476 , D.toSimpleNote
4003 "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:"
4004 , D.indent 4 $ D.vcat $
4478 , D.indent 4 $ D.vcat $
4005− [ "[ \"Alice\""
4479+ [ "[ " <> D.dullyellow "\"Alice\""
4006− , ", \"Bob\""
4480+ , ", " <> D.dullyellow "\"Bob\""
4007− , ", \"Chuck\""
4481+ , ", " <> D.dullyellow "\"Chuck\""
4010 , D.reflow $
4484 , D.reflow $
4011− "Notice that nothing comes directly after a newline. Each line starts with some spaces.\
4485+ "Notice that each line starts with some indentation. Usually two or four spaces.\
4012− \ This style can be jarring for people coming from C-like syntax, but folks generally\
4486+ \ This is the stylistic convention in the Elm ecosystem."
4013− \ report that they are used to it (and often prefer it!) after a week or two of using Elm."
@@ -4063,15 +4536,14 @@ toListReport source context list startRow startCol =
4063 "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\
4064 \ a list across multiple lines, I recommend using this format:"
4537 \ a list across multiple lines, I recommend using this format:"
4065 , D.indent 4 $ D.vcat $
4538 , D.indent 4 $ D.vcat $
4066− [ "[ \"Alice\""
4539+ [ "[ " <> D.dullyellow "\"Alice\""
4067− , ", \"Bob\""
4540+ , ", " <> D.dullyellow "\"Bob\""
4068− , ", \"Chuck\""
4541+ , ", " <> D.dullyellow "\"Chuck\""
4071 , D.reflow $
4544 , D.reflow $
4072− "Notice that nothing comes directly after a newline. Each line starts with some spaces.\
4545+ "Notice that each line starts with some indentation. Usually two or four spaces.\
4073− \ This style can be jarring for people coming from C-like syntax, but folks generally\
4546+ \ This is the stylistic convention in the Elm ecosystem."
4074− \ report that they are used to it (and often prefer it!) after a week or two of using Elm."
@@ -4095,15 +4567,14 @@ toListReport source context list startRow startCol =
4095 "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\
4096 \ a list across multiple lines, I recommend using this format:"
4568 \ a list across multiple lines, I recommend using this format:"
4097 , D.indent 4 $ D.vcat $
4569 , D.indent 4 $ D.vcat $
4098− [ "[ \"Alice\""
4570+ [ "[ " <> D.dullyellow "\"Alice\""
4099− , ", \"Bob\""
4571+ , ", " <> D.dullyellow "\"Bob\""
4100− , ", \"Chuck\""
4572+ , ", " <> D.dullyellow "\"Chuck\""
4103 , D.reflow $
4575 , D.reflow $
4104− "Notice that nothing comes directly after a newline. Each line starts with some spaces.\
4576+ "Notice that each line starts with some indentation. Usually two or four spaces.\
4105− \ This style can be jarring for people coming from C-like syntax, but folks generally\
4577+ \ This is the stylistic convention in the Elm ecosystem."
4106− \ report that they are used to it (and often prefer it!) after a week or two of using Elm."
@@ -4124,15 +4595,14 @@ toListReport source context list startRow startCol =
4124 , D.toSimpleNote
4595 , D.toSimpleNote
4125 "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:"
4126 , D.indent 4 $ D.vcat $
4597 , D.indent 4 $ D.vcat $
4127− [ "[ \"Alice\""
4598+ [ "[ " <> D.dullyellow "\"Alice\""
4128− , ", \"Bob\""
4599+ , ", " <> D.dullyellow "\"Bob\""
4129− , ", \"Chuck\""
4600+ , ", " <> D.dullyellow "\"Chuck\""
4132 , D.reflow $
4603 , D.reflow $
4133− "Notice that nothing comes directly after a newline. Each line starts with some spaces.\
4604+ "Notice that each line starts with some indentation. Usually two or four spaces.\
4134− \ This style can be jarring for people coming from C-like syntax, but folks generally\
4605+ \ This is the stylistic convention in the Elm ecosystem."
4135− \ report that they are used to it (and often prefer it!) after a week or two of using Elm."
@@ -4381,7 +4851,7 @@ toPatternReport source context pattern startRow startCol =
4381 ,"((" <> D.dullyellow "x" <> "," <> D.dullyellow "y" <> ") " <> D.cyan "as" <> D.dullyellow " point" <> ")"
4851 ,"((" <> D.dullyellow "x" <> "," <> D.dullyellow "y" <> ") " <> D.cyan "as" <> D.dullyellow " point" <> ")"
4382 ,"so","you","can","refer","to","individual","parts","of","the","tuple","with"
4852 ,"so","you","can","refer","to","individual","parts","of","the","tuple","with"
4383 ,D.dullyellow "x","and",D.dullyellow "y","or","you","refer","to","the","whole"
4853 ,D.dullyellow "x","and",D.dullyellow "y","or","you","refer","to","the","whole"
4384− ,"thing","with",D.dullyellow "point."
4854+ ,"thing","with",D.dullyellow "point" <> "."
4386 , D.reflow $
4856 , D.reflow $
4387 "So I was expecting to see a variable name after the `as` keyword here. Sometimes\
4857 "So I was expecting to see a variable name after the `as` keyword here. Sometimes\
@@ -4573,7 +5043,7 @@ toPTupleReport source context tuple startRow startCol =
4573 "I just saw an open parenthesis, but I got stuck here:"
5043 "I just saw an open parenthesis, but I got stuck here:"
4575 D.fillSep
5045 D.fillSep
4576− ["I","was","expecting","so","see","a","pattern","next."
5046+ ["I","was","expecting","to","see","a","pattern","next."
4577 ,"Maybe","it","will","end","up","being","something"
5047 ,"Maybe","it","will","end","up","being","something"
4578 ,"like",D.dullyellow "(x,y)","or",D.dullyellow "(name, _)" <> "?"
5048 ,"like",D.dullyellow "(x,y)","or",D.dullyellow "(name, _)" <> "?"
@@ -4682,7 +5152,7 @@ toPTupleReport source context tuple startRow startCol =
4682 "I just saw an open parenthesis, but then I got stuck here:"
5152 "I just saw an open parenthesis, but then I got stuck here:"
4684 D.fillSep
5154 D.fillSep
4685− ["I","was","expecting","so","see","a","pattern","next."
5155+ ["I","was","expecting","to","see","a","pattern","next."
4686 ,"Maybe","it","will","end","up","being","something"
5156 ,"Maybe","it","will","end","up","being","something"
4687 ,"like",D.dullyellow "(x,y)","or",D.dullyellow "(name, _)" <> "?"
5157 ,"like",D.dullyellow "(x,y)","or",D.dullyellow "(name, _)" <> "?"
@@ -4701,7 +5171,7 @@ toPTupleReport source context tuple startRow startCol =
4703 [ D.fillSep
5173 [ D.fillSep
4704− ["I","was","expecting","so","see","a","pattern","next."
5174+ ["I","was","expecting","to","see","a","pattern","next."
4705 ,"I","am","expecting","the","final","result","to","be","something"
5175 ,"I","am","expecting","the","final","result","to","be","something"
4706 ,"like",D.dullyellow "(x,y)","or",D.dullyellow "(name, _)" <> "."
5176 ,"like",D.dullyellow "(x,y)","or",D.dullyellow "(name, _)" <> "."
@@ -5005,22 +5475,64 @@ toTRecordReport source context record startRow startCol =
5005 \ that is a reserved word. Try using a different name!"
5475 \ that is a reserved word. Try using a different name!"
5478+ Code.Other (Just ',') ->
5480+ surroundings = A.Region (A.Position startRow startCol) (A.Position row col)
5481+ region = toRegion row col
5483+ Report.Report "EXTRA COMMA" region [] $
5484+ Code.toSnippet source surroundings (Just region)
5487+ "I am partway through parsing a record type, but I got stuck here:"
5491+ "I am seeing two commas in a row. This is the second one!"
5493+ "Just delete one of the commas and you should be all set!"
5494+ , noteForRecordTypeError
5498+ Code.Close _ '}' ->
5500+ surroundings = A.Region (A.Position startRow startCol) (A.Position row col)
5501+ region = toRegion row col
5503+ Report.Report "EXTRA COMMA" region [] $
5504+ Code.toSnippet source surroundings (Just region)
5507+ "I am partway through parsing a record type, but I got stuck here:"
5511+ "Trailing commas are not allowed in record types. Try deleting the comma that\
5512+ \ appears before this closing curly brace."
5513+ , noteForRecordTypeError
5010 surroundings = A.Region (A.Position startRow startCol) (A.Position row col)
5519 surroundings = A.Region (A.Position startRow startCol) (A.Position row col)
5011 region = toRegion row col
5520 region = toRegion row col
5013− Report.Report "UNFINISHED RECORD TYPE" region [] $
5522+ Report.Report "PROBLEM IN RECORD TYPE" region [] $
5014 Code.toSnippet source surroundings (Just region)
5523 Code.toSnippet source surroundings (Just region)
5016 D.reflow $
5525 D.reflow $
5017− "I am partway through parsing a record type, but I got stuck after that last comma:"
5526+ "I am partway through parsing a record type, but I got stuck here:"
5019− addNoteForRecordTypeError $
5528+ D.stack
5020− D.reflow $
5529+ [ D.fillSep
5021− "Trailing commas are not allowed in records, so I was expecting to see another\
5530+ ["I","was","expecting","to","see","another","record","field","defined","next,"
5022− \ record field defined next. If you are done defining the record, the fix may\
5531+ ,"so","I","am","looking","for","a","name","like"
5023− \ be to delete that last comma?"
5532+ ,D.dullyellow "userName","or",D.dullyellow "plantHeight" <> "."
5534+ , noteForRecordTypeError
5026 TRecordColon row col ->
5538 TRecordColon row col ->
@@ -5034,11 +5546,13 @@ toTRecordReport source context record startRow startCol =
5034 D.reflow $
5546 D.reflow $
5035 "I am partway through parsing a record type, but I got stuck here:"
5547 "I am partway through parsing a record type, but I got stuck here:"
5037− addNoteForRecordTypeError $
5549+ D.stack
5038− D.fillSep $
5550+ [ D.fillSep $
5039− ["I","just","saw","a","field","name,","so","I","was","expecting","to","see"
5551+ ["I","just","saw","a","field","name,","so","I","was","expecting","to","see"
5040− ,"a","colon","next.","So","try","putting","an",D.green ":","sign","here?"
5552+ ,"a","colon","next.","So","try","putting","an",D.green ":","sign","here?"
5554+ , noteForRecordTypeError
5044 TRecordType tipe row col ->
5558 TRecordType tipe row col ->
@@ -5058,29 +5572,54 @@ toTRecordReport source context record startRow startCol =
5058 D.reflow $
5572 D.reflow $
5059 "I just saw the opening curly brace of a record type, but then I got stuck here:"
5573 "I just saw the opening curly brace of a record type, but then I got stuck here:"
5061− addNoteForRecordTypeIndentError $
5575+ D.stack
5062− D.fillSep $
5576+ [ D.fillSep $
5063− ["I","am","expecting","a","record","like",D.dullyellow "{ name : String, age : Int }","here."
5577+ ["I","am","expecting","a","record","like",D.dullyellow "{ name : String, age : Int }","here."
5064− ,"Try","defining","some","fields","of","your","own?"
5578+ ,"Try","defining","some","fields","of","your","own?"
5580+ , noteForRecordTypeIndentError
5068 TRecordIndentEnd row col ->
5584 TRecordIndentEnd row col ->
5585+ case Code.nextLineStartsWithCloseCurly source row of
5586+ Just (curlyRow, curlyCol) ->
5588+ surroundings = A.Region (A.Position startRow startCol) (A.Position curlyRow curlyCol)
5589+ region = toRegion curlyRow curlyCol
5591+ Report.Report "NEED MORE INDENTATION" region [] $
5592+ Code.toSnippet source surroundings (Just region)
5595+ "I was partway through parsing a record type, but I got stuck here:"
5599+ "I need this curly brace to be indented more. Try adding some spaces before it!"
5600+ , noteForRecordTypeError
5070− surroundings = A.Region (A.Position startRow startCol) (A.Position row col)
5606+ surroundings = A.Region (A.Position startRow startCol) (A.Position row col)
5071− region = toRegion row col
5607+ region = toRegion row col
5073− Report.Report "UNFINISHED RECORD TYPE" region [] $
5609+ Report.Report "UNFINISHED RECORD TYPE" region [] $
5074− Code.toSnippet source surroundings (Just region)
5610+ Code.toSnippet source surroundings (Just region)
5076− D.reflow $
5612+ D.reflow $
5613+ "I was partway through parsing a record type, but I got stuck here:"
5077− "I was expecting to see a closing curly brace next:"
5617+ ["I","was","expecting","to","see","a","closing","curly","brace","next."
5079− addNoteForRecordTypeIndentError $
5081− ["Try","putting","an",D.green "}","and","see","if","that","helps?"
5618+ ,"Try","putting","a",D.green "}","next","and","see","if","that","helps?"
5620+ , noteForRecordTypeIndentError
5085 TRecordIndentField row col ->
5624 TRecordIndentField row col ->
@@ -5093,11 +5632,13 @@ toTRecordReport source context record startRow startCol =
5093 D.reflow $
5632 D.reflow $
5094 "I am partway through parsing a record type, but I got stuck after that last comma:"
5633 "I am partway through parsing a record type, but I got stuck after that last comma:"
5096− addNoteForRecordTypeIndentError $
5635+ D.stack
5097− D.reflow $
5636+ [ D.reflow $
5098− "Trailing commas are not allowed in record types, so the fix may be to\
5637+ "Trailing commas are not allowed in record types, so the fix may be to\
5099− \ delete that last comma? Or maybe you were in the middle of defining\
5638+ \ delete that last comma? Or maybe you were in the middle of defining\
5100− \ an additional field?"
5639+ \ an additional field?"
5640+ , noteForRecordTypeIndentError
5103 TRecordIndentColon row col ->
5644 TRecordIndentColon row col ->
@@ -5112,10 +5653,12 @@ toTRecordReport source context record startRow startCol =
5112 "I am partway through parsing a record type. I just saw a record\
5653 "I am partway through parsing a record type. I just saw a record\
5113 \ field, so I was expecting to see a colon next:"
5654 \ field, so I was expecting to see a colon next:"
5115− addNoteForRecordTypeIndentError $
5656+ D.stack
5116− D.fillSep $
5657+ [ D.fillSep $
5117− ["Try","putting","an",D.green ":","followed","by","a","type?"
5658+ ["Try","putting","an",D.green ":","followed","by","a","type?"
5660+ , noteForRecordTypeIndentError
5121 TRecordIndentType row col ->
5664 TRecordIndentType row col ->
@@ -5129,19 +5672,19 @@ toTRecordReport source context record startRow startCol =
5129 D.reflow $
5672 D.reflow $
5130 "I am partway through parsing a record type, and I was expecting to run into a type next:"
5673 "I am partway through parsing a record type, and I was expecting to run into a type next:"
5132− addNoteForRecordTypeIndentError $
5675+ D.stack
5133− D.fillSep $
5676+ [ D.fillSep $
5134− ["Try","putting","something","like"
5677+ ["Try","putting","something","like"
5135− ,D.dullyellow "Int","or",D.dullyellow "String","for","now?"
5678+ ,D.dullyellow "Int","or",D.dullyellow "String","for","now?"
5680+ , noteForRecordTypeIndentError
5140−addNoteForRecordTypeError :: D.Doc -> D.Doc
5685+noteForRecordTypeError :: D.Doc
5141−addNoteForRecordTypeError normalRecommendation =
5686+noteForRecordTypeError =
5142 D.stack $
5687 D.stack $
5143− normalRecommendation
5145 [ D.toSimpleNote
5688 [ D.toSimpleNote
5146 "If you are trying to define a record type across multiple lines, I recommend using this format:"
5689 "If you are trying to define a record type across multiple lines, I recommend using this format:"
5147 , D.indent 4 $ D.vcat $
5690 , D.indent 4 $ D.vcat $
@@ -5151,17 +5694,14 @@ addNoteForRecordTypeError normalRecommendation =
5153 , D.reflow $
5696 , D.reflow $
5154− "Notice that each line starts with some indentation. Usually two or four spaces. I\
5697+ "Notice that each line starts with some indentation. Usually two or four spaces.\
5155− \ know this style can be jarring for people coming from C-like syntax, but folks generally\
5698+ \ This is the stylistic convention in the Elm ecosystem."
5156− \ report that they are used to it (and often prefer it!) after a week or two of using Elm."
5160−addNoteForRecordTypeIndentError :: D.Doc -> D.Doc
5702+noteForRecordTypeIndentError :: D.Doc
5161−addNoteForRecordTypeIndentError normalRecommendation =
5703+noteForRecordTypeIndentError =
5162 D.stack $
5704 D.stack $
5163− normalRecommendation
5165 [ D.toSimpleNote
5705 [ D.toSimpleNote
5166 "I may be confused by indentation. For example, if you are trying to define\
5706 "I may be confused by indentation. For example, if you are trying to define\
5167 \ a record type across multiple lines, I recommend using this format:"
5707 \ a record type across multiple lines, I recommend using this format:"
@@ -5172,9 +5712,8 @@ addNoteForRecordTypeIndentError normalRecommendation =
5174 , D.reflow $
5714 , D.reflow $
5175− "Notice that each line starts with some indentation. Usually two or four spaces. I\
5715+ "Notice that each line starts with some indentation. Usually two or four spaces.\
5176− \ know this style can be jarring for people coming from C-like syntax, but folks generally\
5716+ \ This is the stylistic convention in the Elm ecosystem."
5177− \ report that they are used to it (and often prefer it!) after a week or two of using Elm."
@@ -5226,7 +5765,7 @@ toTTupleReport source context tuple startRow startCol =
5226 Code.toSnippet source surroundings (Just region)
5765 Code.toSnippet source surroundings (Just region)
5228 D.reflow $
5767 D.reflow $
5229− "I was expecting to see a closing parentheses next, but I got stuck here:"
5768+ "I was expecting to see a closing parenthesis next, but I got stuck here:"
5232 [ D.fillSep ["Try","adding","a",D.dullyellow ")","to","see","if","that","helps?"]
5771 [ D.fillSep ["Try","adding","a",D.dullyellow ")","to","see","if","that","helps?"]