on master help sign in
improve a bunch of syntax error messages
c8e3b8aEvan Czaplicki
compiler/src/Reporting/Error/Syntax.hs+199−128
@@ -693,6 +693,36 @@ toParseErrorReport source modul =
693 "This " ++ bracket : " does not match up with an earlier open " ++ term ++ ". Try deleting it?"
693 "This " ++ bracket : " does not match up with an earlier open " ++ term ++ ". Try deleting it?"
694 )
694 )
695
695
696+ Code.Lower c cs ->
697+ let
698+ region = toKeywordRegion row col (c:cs)
699+ in
700+ Report.Report "UNEXPECTED NAME" region [] $
701+ Code.toSnippet source region Nothing
702+ (
703+ D.reflow $
704+ "I got stuck on this name:"
705+ ,
706+ D.reflow $
707+ "It is confusing me a lot! Normally I can give fairly specific hints, but\
708+ \ something is really tripping me up this time."
709+ )
710+
711+ Code.Upper c cs ->
712+ let
713+ region = toKeywordRegion row col (c:cs)
714+ in
715+ Report.Report "UNEXPECTED NAME" region [] $
716+ Code.toSnippet source region Nothing
717+ (
718+ D.reflow $
719+ "I got stuck on this name:"
720+ ,
721+ D.reflow $
722+ "It is confusing me a lot! Normally I can give fairly specific hints, but\
723+ \ something is really tripping me up this time."
724+ )
725+
696 Code.Other maybeChar ->
726 Code.Other maybeChar ->
697 let
727 let
698 region = toRegion row col
728 region = toRegion row col
@@ -747,17 +777,15 @@ toParseErrorReport source modul =
747 "It is not used for anything in Elm syntax. It is used for multi-line strings in\
777 "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\
778 \ 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:"
779 \ can use Elm's multi-line string syntax like this:"
750− , D.vcat
780+ , D.dullyellow $ D.indent 4 $ D.vcat $
751− [ D.fillSep [D.green "markdown","=",D.dullyellow "\"\"\""]
781+ [ "\"\"\""
752− , mempty
753− , D.dullyellow "# Multi-line Strings"
782+ , "# Multi-line Strings"
754− , mempty
783+ , ""
755− , D.dullyellow "- start with triple double quotes"
784+ , "- start with triple double quotes"
756− , D.dullyellow "- write whatever you want"
785+ , "- write whatever you want"
757− , D.dullyellow "- no need to escape newlines or double quotes"
786+ , "- no need to escape newlines or double quotes"
758− , D.dullyellow "- end with triple double quotes"
787+ , "- end with triple double quotes"
759− , mempty
760− , D.dullyellow "\"\"\""
788+ , "\"\"\""
761 ]
789 ]
762 , D.reflow $
790 , D.reflow $
763 "Otherwise I do not know what is going on! Try removing the character?"
791 "Otherwise I do not know what is going on! Try removing the character?"
@@ -944,11 +972,11 @@ toParseErrorReport source modul =
944 [ D.reflow $
972 [ D.reflow $
945 "I am not sure what is going on, but I recommend starting an Elm\
973 "I am not sure what is going on, but I recommend starting an Elm\
946 \ file with the following lines:"
974 \ file with the following lines:"
947− , D.vcat
975+ , D.indent 4 $ D.vcat $
948 [ D.fillSep [D.cyan "import","Html"]
976 [ D.fillSep [D.cyan "import","Html"]
949 , ""
977 , ""
950− , D.fillSep [D.green "main","="]
978+ , "main ="
951− , D.indent 2 $ D.fillSep [D.cyan "Html" <> ".text",D.dullyellow "\"Hello!\""]
979+ , " Html.text " <> D.dullyellow "\"Hello!\""
952 ]
980 ]
953 , D.reflow $
981 , D.reflow $
954 "You should be able to copy those lines directly into your file. Check out the\
982 "You should be able to copy those lines directly into your file. Check out the\
@@ -977,8 +1005,8 @@ toParseErrorReport source modul =
977 , D.indent 4 $ D.vcat $
1005 , D.indent 4 $ D.vcat $
978 [ D.fillSep [D.cyan "import","Dict"]
1006 [ D.fillSep [D.cyan "import","Dict"]
979 , D.fillSep [D.cyan "import","Maybe"]
1007 , D.fillSep [D.cyan "import","Maybe"]
980− , D.fillSep [D.cyan "import","Html.Attributes"]
1008+ , D.fillSep [D.cyan "import","Html.Attributes",D.cyan "as","A"]
981− , D.fillSep [D.cyan "import","Json.Decode"]
1009+ , D.fillSep [D.cyan "import","Json.Decode",D.cyan "exposing","(..)"]
982 ]
1010 ]
983 , D.reflow $
1011 , D.reflow $
984 "Notice that the module names all start with capital letters. That is required!"
1012 "Notice that the module names all start with capital letters. That is required!"
@@ -1439,8 +1467,8 @@ toDeclarationsReport source decl =
1439 , D.toSimpleNote $
1467 , D.toSimpleNote $
1440 "If you are trying to write a `case` expression, it needs to be part of a\
1468 "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:"
1469 \ definition. So you could write something like this instead:"
1442− , D.vcat $
1470+ , D.indent 4 $ D.vcat $
1443− [ D.indent 0 $ D.fillSep [D.green "getWidth","maybeWidth","="]
1471+ [ D.indent 0 $ D.fillSep ["getWidth","maybeWidth","="]
1444 , D.indent 2 $ D.fillSep [D.cyan "case","maybeWidth",D.cyan "of"]
1472 , D.indent 2 $ D.fillSep [D.cyan "case","maybeWidth",D.cyan "of"]
1445 , D.indent 4 $ D.fillSep [D.blue "Just","width","->"]
1473 , D.indent 4 $ D.fillSep [D.blue "Just","width","->"]
1446 , D.indent 6 $ D.fillSep ["width","+",D.dullyellow "200"]
1474 , D.indent 6 $ D.fillSep ["width","+",D.dullyellow "200"]
@@ -1449,7 +1477,7 @@ toDeclarationsReport source decl =
1449 , D.indent 6 $ D.fillSep [D.dullyellow "400"]
1477 , D.indent 6 $ D.fillSep [D.dullyellow "400"]
1450 ]
1478 ]
1451 , D.reflow $
1479 , D.reflow $
1452− "This defines a `getWidth` function that we can use elsewhere in our program."
1480+ "This defines a `getWidth` function that you can use elsewhere in your program."
1453 ]
1481 ]
1454
1482
1455 "if" ->
1483 "if" ->
@@ -1459,16 +1487,17 @@ toDeclarationsReport source decl =
1459 , D.toSimpleNote $
1487 , D.toSimpleNote $
1460 "If you are trying to write an `if` expression, it needs to be part of a\
1488 "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:"
1489 \ definition. So you could write something like this instead:"
1462− , D.vcat $
1490+ , D.indent 4 $ D.vcat $
1463− [ D.indent 0 $ D.fillSep [D.green "reviewPowerLevel","powerLevel","="]
1491+ [ "greet name ="
1464− , D.indent 2 $ D.fillSep $
1492+ , D.fillSep $
1493+ [" "
1465− [D.cyan "if","powerLevel",">",D.dullyellow "9000"
1494+ ,D.cyan "if","name","==",D.dullyellow "\"Abraham Lincoln\""
1466− ,D.cyan "then",D.dullyellow "\"OVER 9000!!!\""
1495+ ,D.cyan "then",D.dullyellow "\"Greetings Mr. President.\""
1467− ,D.cyan "else",D.dullyellow "\"not bad\""
1496+ ,D.cyan "else",D.dullyellow "\"Hey!\""
1468 ]
1497 ]
1469 ]
1498 ]
1470 , D.reflow $
1499 , D.reflow $
1471− "This defines a `reviewPowerLevel` function that we can use elsewhere in our program."
1500+ "This defines a `reviewPowerLevel` function that you can use elsewhere in your program."
1472 ]
1501 ]
1473
1502
1474 _ ->
1503 _ ->
@@ -1476,37 +1505,83 @@ toDeclarationsReport source decl =
1476 "It is a reserved word. Try changing the name to something else?"
1505 "It is a reserved word. Try changing the name to something else?"
1477 )
1506 )
1478
1507
1479− _ ->
1508+ Code.Upper c cs ->
1480 let
1509 let
1481 region = toRegion row col
1510 region = toRegion row col
1482 in
1511 in
1483− Report.Report "SYNTAX PROBLEM" region [] $
1512+ Report.Report "UNEXPECTED CAPITAL LETTER" region [] $
1484 Code.toSnippet source region Nothing
1513 Code.toSnippet source region Nothing
1485 (
1514 (
1486 D.reflow $
1515 D.reflow $
1487− "I was expecting to see a declaration, but I am getting stuck here:"
1516+ "Declarations always start with a lower-case letter, so I am getting stuck here:"
1488 ,
1517 ,
1489 D.stack
1518 D.stack
1490− [ case Code.whatIsNext source row col of
1519+ [ D.fillSep $
1491− Code.Other (Just char) | Char.isUpper char ->
1520+ ["Try","a","name","like"
1492− D.reflow $
1521+ ,D.green (D.fromChars (Char.toLower c : cs))
1493− "All declarations start with lower-case letters in Elm, so maybe this letter can\
1522+ ,"instead?"
1494− \ be changed to lower-case?"
1523+ ]
1495−
1524+ , D.toSimpleNote $
1496− _ ->
1497− D.reflow $
1498− "Declarations normally start with a lower-case name or the `type` keyword."
1499− , D.toSimpleHint $
1500 "Here are a couple valid declarations for reference:"
1525 "Here are a couple valid declarations for reference:"
1501− , D.vcat
1526+ , D.indent 4 $ D.vcat $
1502− [ D.fillSep [D.green "add",":","Int","->","Int","->","Int"]
1527+ [ "greet : String -> String"
1503− , D.fillSep [D.green "add","x","y","="]
1528+ , "greet name ="
1504− , D.fillSep [" ","x","+","y"]
1529+ , " " <> D.dullyellow "\"Hello \"" <> " ++ name ++ " <> D.dullyellow "\"!\""
1530+ , ""
1531+ , D.cyan "type" <> " User = Anonymous | LoggedIn String"
1532+ ]
1533+ , D.reflow $
1534+ "Notice that they always start with a lower-case letter. Capitalization matters!"
1535+ ]
1536+ )
1537+
1538+ Code.Other (Just char) | elem char ['(', '{', '[', '+', '-', '*', '/', '^', '&', '|', '"', '\'', '!', '@', '#', '$', '%'] ->
1539+ let
1540+ region = toRegion row col
1541+ in
1542+ Report.Report "UNEXPECTED SYMBOL" region [] $
1543+ Code.toSnippet source region Nothing
1544+ (
1545+ D.reflow $
1546+ "I am getting stuck because this line starts with the " ++ [char] ++ " symbol:"
1547+ ,
1548+ D.stack
1549+ [ D.reflow $
1550+ "When a line has no spaces at the beginning, I expect it to be a declaration like one of these:"
1551+ , D.indent 4 $ D.vcat $
1552+ [ "greet : String -> String"
1553+ , "greet name ="
1554+ , " " <> D.dullyellow "\"Hello \"" <> " ++ name ++ " <> D.dullyellow "\"!\""
1555+ , ""
1556+ , D.cyan "type" <> " User = Anonymous | LoggedIn String"
1557+ ]
1558+ , D.reflow $
1559+ "If this is not supposed to be a declaration, try adding some spaces before it?"
1560+ ]
1561+ )
1562+
1563+ _ ->
1564+ let
1565+ region = toRegion row col
1566+ in
1567+ Report.Report "WEIRD DECLARATION" region [] $
1568+ Code.toSnippet source region Nothing
1569+ (
1570+ D.reflow $
1571+ "I am trying to parse a declaration, but I am getting stuck here:"
1572+ ,
1573+ D.stack
1574+ [ D.reflow $
1575+ "I am not sure what is going wrong, so here are a couple valid declarations for reference:"
1576+ , D.indent 4 $ D.vcat $
1577+ [ "greet : String -> String"
1578+ , "greet name ="
1579+ , " " <> D.dullyellow "\"Hello \"" <> " ++ name ++ " <> D.dullyellow "\"!\""
1580+ , ""
1581+ , D.cyan "type" <> " User = Anonymous | LoggedIn String"
1505 ]
1582 ]
1506− , D.fillSep [D.cyan "type",D.green "User","=","Anonymous","|","LoggedIn String"]
1507 , D.reflow $
1583 , D.reflow $
1508− "Notice that these declarations start with lower-case letters. Capitalization\
1584+ "Try to make your declaration look like one of those?"
1509− \ makes a difference in Elm!"
1510 ]
1585 ]
1511 )
1586 )
1512
1587
@@ -1664,7 +1739,7 @@ toPortReport source port_ startRow startCol =
1664 [ D.reflow $
1739 [ D.reflow $
1665 "I was expecting to see a type next. Here are examples of outgoing and\
1740 "I was expecting to see a type next. Here are examples of outgoing and\
1666 \ incoming ports for reference:"
1741 \ incoming ports for reference:"
1667− , D.vcat
1742+ , D.indent 4 $ D.vcat $
1668 [ D.fillSep [D.cyan "port","send",":","String -> Cmd msg"]
1743 [ D.fillSep [D.cyan "port","send",":","String -> Cmd msg"]
1669 , D.fillSep [D.cyan "port","receive",":","(String -> msg) -> Sub msg"]
1744 , D.fillSep [D.cyan "port","receive",":","(String -> msg) -> Sub msg"]
1670 ]
1745 ]
@@ -1683,7 +1758,7 @@ portNote =
1683 D.stack
1758 D.stack
1684 [ D.toSimpleNote $
1759 [ D.toSimpleNote $
1685 "Here are some example `port` declarations for reference:"
1760 "Here are some example `port` declarations for reference:"
1686− , D.vcat
1761+ , D.indent 4 $ D.vcat $
1687 [ D.fillSep [D.cyan "port","send",":","String -> Cmd msg"]
1762 [ D.fillSep [D.cyan "port","send",":","String -> Cmd msg"]
1688 , D.fillSep [D.cyan "port","receive",":","(String -> msg) -> Sub msg"]
1763 , D.fillSep [D.cyan "port","receive",":","(String -> msg) -> Sub msg"]
1689 ]
1764 ]
@@ -1866,8 +1941,8 @@ typeAliasNote =
1866 [ D.toSimpleNote $
1941 [ D.toSimpleNote $
1867 "Here is an example of a valid `type alias` for reference:"
1942 "Here is an example of a valid `type alias` for reference:"
1868 , D.vcat $
1943 , D.vcat $
1869− [ D.indent 0 $ D.fillSep [D.cyan "type",D.cyan "alias",D.green "Person","="]
1944+ [ D.indent 4 $ D.fillSep [D.cyan "type",D.cyan "alias","Person","="]
1870− , D.indent 2 $ D.vcat $
1945+ , D.indent 6 $ D.vcat $
1871 ["{ name : String"
1946 ["{ name : String"
1872 ,", age : Int"
1947 ,", age : Int"
1873 ,", height : Float"
1948 ,", height : Float"
@@ -2067,10 +2142,10 @@ customTypeNote =
2067 [ D.toSimpleNote $
2142 [ D.toSimpleNote $
2068 "Here is an example of a valid `type` declaration for reference:"
2143 "Here is an example of a valid `type` declaration for reference:"
2069 , D.vcat $
2144 , D.vcat $
2070− [ D.indent 0 $ D.fillSep [D.cyan "type",D.green "Status"]
2145+ [ D.indent 4 $ D.fillSep [D.cyan "type","Status"]
2071− , D.indent 2 $ D.fillSep ["=","Failure"]
2146+ , D.indent 6 $ D.fillSep ["=","Failure"]
2072− , D.indent 2 $ D.fillSep ["|","Waiting"]
2147+ , D.indent 6 $ D.fillSep ["|","Waiting"]
2073− , D.indent 2 $ D.fillSep ["|","Success","String"]
2148+ , D.indent 6 $ D.fillSep ["|","Success","String"]
2074 ]
2149 ]
2075 , D.reflow $
2150 , D.reflow $
2076 "This defines a new `Status` type with three variants. This could be useful if\
2151 "This defines a new `Status` type with three variants. This could be useful if\
@@ -2142,10 +2217,10 @@ toDeclDefReport source name declDef startRow startCol =
2142 ,"a","type","annotation.","It","could","be","something","else","though,","so"
2217 ,"a","type","annotation.","It","could","be","something","else","though,","so"
2143 ,"here","is","a","valid","definition","for","reference:"
2218 ,"here","is","a","valid","definition","for","reference:"
2144 ]
2219 ]
2145− , D.vcat
2220+ , D.indent 4 $ D.vcat $
2146− [ D.fillSep [D.green "add",":","Int","->","Int","->","Int"]
2221+ [ "greet : String -> String"
2147− , D.fillSep [D.green "add","x","y","="]
2222+ , "greet name ="
2148− , D.fillSep [" ","x","+","y"]
2223+ , " " <> D.dullyellow "\"Hello \"" <> " ++ name ++ " <> D.dullyellow "\"!\""
2149 ]
2224 ]
2150 , D.reflow $
2225 , D.reflow $
2151 "Try to use that format with your `" ++ Name.toChars name ++ "` definition!"
2226 "Try to use that format with your `" ++ Name.toChars name ++ "` definition!"
@@ -2167,10 +2242,10 @@ toDeclDefReport source name declDef startRow startCol =
2167 [ D.reflow $
2242 [ D.reflow $
2168 "I am not sure what is going wrong exactly, so here is a valid\
2243 "I am not sure what is going wrong exactly, so here is a valid\
2169 \ definition (with an optional type annotation) for reference:"
2244 \ definition (with an optional type annotation) for reference:"
2170− , D.vcat
2245+ , D.indent 4 $ D.vcat $
2171− [ D.fillSep [D.green "add",":","Int","->","Int","->","Int"]
2246+ [ "greet : String -> String"
2172− , D.fillSep [D.green "add","x","y","="]
2247+ , "greet name ="
2173− , D.fillSep [" ","x","+","y"]
2248+ , " " <> D.dullyellow "\"Hello \"" <> " ++ name ++ " <> D.dullyellow "\"!\""
2174 ]
2249 ]
2175 , D.reflow $
2250 , D.reflow $
2176 "Try to use that format with your `" ++ Name.toChars name ++ "` definition!"
2251 "Try to use that format with your `" ++ Name.toChars name ++ "` definition!"
@@ -2192,10 +2267,10 @@ toDeclDefReport source name declDef startRow startCol =
2192 [ D.reflow $
2267 [ D.reflow $
2193 "I am not sure what is going wrong exactly, so here is a valid\
2268 "I am not sure what is going wrong exactly, so here is a valid\
2194 \ definition (with an optional type annotation) for reference:"
2269 \ definition (with an optional type annotation) for reference:"
2195− , D.vcat
2270+ , D.indent 4 $ D.vcat $
2196− [ D.fillSep [D.green "add",":","Int","->","Int","->","Int"]
2271+ [ "greet : String -> String"
2197− , D.fillSep [D.green "add","x","y","="]
2272+ , "greet name ="
2198− , D.fillSep [" ","x","+","y"]
2273+ , " " <> D.dullyellow "\"Hello \"" <> " ++ name ++ " <> D.dullyellow "\"!\""
2199 ]
2274 ]
2200 , D.reflow $
2275 , D.reflow $
2201 "Try to use that format!"
2276 "Try to use that format!"
@@ -2310,10 +2385,10 @@ declDefNote =
2310 D.stack
2385 D.stack
2311 [ D.reflow $
2386 [ D.reflow $
2312 "Here is a valid definition (with a type annotation) for reference:"
2387 "Here is a valid definition (with a type annotation) for reference:"
2313− , D.vcat
2388+ , D.indent 4 $ D.vcat $
2314− [ D.fillSep [D.green "add",":","Int","->","Int","->","Int"]
2389+ [ "greet : String -> String"
2315− , D.fillSep [D.green "add","x","y","="]
2390+ , "greet name ="
2316− , D.fillSep [" ","x","+","y"]
2391+ , " " <> D.dullyellow "\"Hello \"" <> " ++ name ++ " <> D.dullyellow "\"!\""
2317 ]
2392 ]
2318 , D.reflow $
2393 , D.reflow $
2319 "The top line (called a \"type annotation\") is optional. You can leave it off\
2394 "The top line (called a \"type annotation\") is optional. You can leave it off\
@@ -2646,17 +2721,15 @@ toStringReport source string row col =
2646 , D.toSimpleNote $
2721 , D.toSimpleNote $
2647 "For a string that spans multiple lines, you can use the multi-line string\
2722 "For a string that spans multiple lines, you can use the multi-line string\
2648 \ syntax like this:"
2723 \ syntax like this:"
2649− , D.vcat
2724+ , D.dullyellow $ D.indent 4 $ D.vcat $
2650− [ D.fillSep [D.green "markdown","=",D.dullyellow "\"\"\""]
2725+ [ "\"\"\""
2651− , mempty
2652− , D.dullyellow "# Multi-line Strings"
2726+ , "# Multi-line Strings"
2653− , mempty
2727+ , ""
2654− , D.dullyellow "- start with triple double quotes"
2728+ , "- start with triple double quotes"
2655− , D.dullyellow "- write whatever you want"
2729+ , "- write whatever you want"
2656− , D.dullyellow "- no need to escape newlines or double quotes"
2730+ , "- no need to escape newlines or double quotes"
2657− , D.dullyellow "- end with triple double quotes"
2731+ , "- end with triple double quotes"
2658− , mempty
2659− , D.dullyellow "\"\"\""
2732+ , "\"\"\""
2660 ]
2733 ]
2661 ]
2734 ]
2662 )
2735 )
@@ -2675,17 +2748,15 @@ toStringReport source string row col =
2675 [ D.reflow "Add a \"\"\" somewhere after this to end the string."
2748 [ D.reflow "Add a \"\"\" somewhere after this to end the string."
2676 , D.toSimpleNote $
2749 , D.toSimpleNote $
2677 "Here is a valid multi-line string for reference:"
2750 "Here is a valid multi-line string for reference:"
2678− , D.vcat
2751+ , D.dullyellow $ D.indent 4 $ D.vcat $
2679− [ D.fillSep [D.green "markdown","=",D.dullyellow "\"\"\""]
2752+ [ "\"\"\""
2680− , mempty
2681− , D.dullyellow "# Multi-line Strings"
2753+ , "# Multi-line Strings"
2682− , mempty
2754+ , ""
2683− , D.dullyellow "- start with triple double quotes"
2755+ , "- start with triple double quotes"
2684− , D.dullyellow "- write whatever you want"
2756+ , "- write whatever you want"
2685− , D.dullyellow "- no need to escape newlines or double quotes"
2757+ , "- no need to escape newlines or double quotes"
2686− , D.dullyellow "- end with triple double quotes"
2758+ , "- end with triple double quotes"
2687− , mempty
2688− , D.dullyellow "\"\"\""
2759+ , "\"\"\""
2689 ]
2760 ]
2690 ]
2761 ]
2691 )
2762 )
@@ -3150,8 +3221,8 @@ toUnfinishLetReport source row col startRow startCol message =
3150 [ message
3221 [ message
3151 , D.toSimpleNote $
3222 , D.toSimpleNote $
3152 "Here is an example with a valid `let` expression for reference:"
3223 "Here is an example with a valid `let` expression for reference:"
3153− , D.vcat $
3224+ , D.indent 4 $ D.vcat $
3154− [ D.indent 0 $ D.fillSep [D.green "viewPerson","person","="]
3225+ [ D.indent 0 $ D.fillSep ["viewPerson","person","="]
3155 , D.indent 2 $ D.fillSep [D.cyan "let"]
3226 , D.indent 2 $ D.fillSep [D.cyan "let"]
3156 , D.indent 4 $ D.fillSep ["fullName","="]
3227 , D.indent 4 $ D.fillSep ["fullName","="]
3157 , D.indent 6 $ D.fillSep ["person.firstName","++",D.dullyellow "\" \"","++","person.lastName"]
3228 , D.indent 6 $ D.fillSep ["person.firstName","++",D.dullyellow "\" \"","++","person.lastName"]
@@ -3269,10 +3340,10 @@ toLetDefReport source name def startRow startCol =
3269 ,"a","type","annotation.","It","could","be","something","else","though,","so"
3340 ,"a","type","annotation.","It","could","be","something","else","though,","so"
3270 ,"here","is","a","valid","definition","for","reference:"
3341 ,"here","is","a","valid","definition","for","reference:"
3271 ]
3342 ]
3272− , D.vcat
3343+ , D.indent 4 $ D.vcat $
3273− [ D.indent 4 $ D.fillSep [D.green "add",":","Int","->","Int","->","Int"]
3344+ [ "greet : String -> String"
3274− , D.indent 4 $ D.fillSep [D.green "add","x","y","="]
3345+ , "greet name ="
3275− , D.indent 6 $ D.fillSep ["x","+","y"]
3346+ , " " <> D.dullyellow "\"Hello \"" <> " ++ name ++ " <> D.dullyellow "\"!\""
3276 ]
3347 ]
3277 , D.reflow $
3348 , D.reflow $
3278 "Try to use that format with your `" ++ Name.toChars name ++ "` definition!"
3349 "Try to use that format with your `" ++ Name.toChars name ++ "` definition!"
@@ -3294,10 +3365,10 @@ toLetDefReport source name def startRow startCol =
3294 [ D.reflow $
3365 [ D.reflow $
3295 "I am not sure what is going wrong exactly, so here is a valid\
3366 "I am not sure what is going wrong exactly, so here is a valid\
3296 \ definition (with an optional type annotation) for reference:"
3367 \ definition (with an optional type annotation) for reference:"
3297− , D.vcat
3368+ , D.indent 4 $ D.vcat $
3298− [ D.indent 4 $ D.fillSep [D.green "add",":","Int","->","Int","->","Int"]
3369+ [ "greet : String -> String"
3299− , D.indent 4 $ D.fillSep [D.green "add","x","y","="]
3370+ , "greet name ="
3300− , D.indent 6 $ D.fillSep ["x","+","y"]
3371+ , " " <> D.dullyellow "\"Hello \"" <> " ++ name ++ " <> D.dullyellow "\"!\""
3301 ]
3372 ]
3302 , D.reflow $
3373 , D.reflow $
3303 "Try to use that format with your `" ++ Name.toChars name ++ "` definition!"
3374 "Try to use that format with your `" ++ Name.toChars name ++ "` definition!"
@@ -3319,10 +3390,10 @@ toLetDefReport source name def startRow startCol =
3319 [ D.reflow $
3390 [ D.reflow $
3320 "I am not sure what is going wrong exactly, so here is a valid\
3391 "I am not sure what is going wrong exactly, so here is a valid\
3321 \ definition (with an optional type annotation) for reference:"
3392 \ definition (with an optional type annotation) for reference:"
3322− , D.vcat
3393+ , D.indent 4 $ D.vcat $
3323− [ D.indent 4 $ D.fillSep [D.green "add",":","Int","->","Int","->","Int"]
3394+ [ "greet : String -> String"
3324− , D.indent 4 $ D.fillSep [D.green "add","x","y","="]
3395+ , "greet name ="
3325− , D.indent 4 $ D.fillSep ["x","+","y"]
3396+ , " " <> D.dullyellow "\"Hello \"" <> " ++ name ++ " <> D.dullyellow "\"!\""
3326 ]
3397 ]
3327 , D.reflow $
3398 , D.reflow $
3328 "Try to use that format!"
3399 "Try to use that format!"
@@ -3412,10 +3483,10 @@ defNote =
3412 D.stack
3483 D.stack
3413 [ D.reflow $
3484 [ D.reflow $
3414 "Here is a valid definition (with a type annotation) for reference:"
3485 "Here is a valid definition (with a type annotation) for reference:"
3415− , D.vcat
3486+ , D.indent 4 $ D.vcat $
3416− [ D.indent 4 $ D.fillSep [D.green "add",":","Int","->","Int","->","Int"]
3487+ [ "greet : String -> String"
3417− , D.indent 4 $ D.fillSep [D.green "add","x","y","="]
3488+ , "greet name ="
3418− , D.indent 6 $ D.fillSep ["x","+","y"]
3489+ , " " <> D.dullyellow "\"Hello \"" <> " ++ name ++ " <> D.dullyellow "\"!\""
3419 ]
3490 ]
3420 , D.reflow $
3491 , D.reflow $
3421 "The top line (called a \"type annotation\") is optional. You can leave it off\
3492 "The top line (called a \"type annotation\") is optional. You can leave it off\
@@ -4164,9 +4235,9 @@ noteForRecordError =
4164 [ D.toSimpleNote
4235 [ D.toSimpleNote
4165 "If you are trying to define a record across multiple lines, I recommend using this format:"
4236 "If you are trying to define a record across multiple lines, I recommend using this format:"
4166 , D.indent 4 $ D.vcat $
4237 , D.indent 4 $ D.vcat $
4167− [ "{ name = \"Alice\""
4238+ [ "{ name = " <> D.dullyellow "\"Alice\""
4168− , ", age = 42"
4239+ , ", age = " <> D.dullyellow "42"
4169− , ", height = 1.75"
4240+ , ", height = " <> D.dullyellow "1.75"
4170 , "}"
4241 , "}"
4171 ]
4242 ]
4172 , D.reflow $
4243 , D.reflow $
@@ -4184,9 +4255,9 @@ addNoteForRecordIndentError normalRecommendation =
4184 "I may be confused by indentation. For example, if you are trying to define\
4255 "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:"
4256 \ a record across multiple lines, I recommend using this format:"
4186 , D.indent 4 $ D.vcat $
4257 , D.indent 4 $ D.vcat $
4187− [ "{ name = \"Alice\""
4258+ [ "{ name = " <> D.dullyellow "\"Alice\""
4188− , ", age = 42"
4259+ , ", age = " <> D.dullyellow "42"
4189− , ", height = 1.75"
4260+ , ", height = " <> D.dullyellow "1.75"
4190 , "}"
4261 , "}"
4191 ]
4262 ]
4192 , D.reflow $
4263 , D.reflow $
@@ -4380,9 +4451,9 @@ toListReport source context list startRow startCol =
4380 , D.toSimpleNote
4451 , D.toSimpleNote
4381 "I recommend using the following format for lists that span multiple lines:"
4452 "I recommend using the following format for lists that span multiple lines:"
4382 , D.indent 4 $ D.vcat $
4453 , D.indent 4 $ D.vcat $
4383− [ "[ \"Alice\""
4454+ [ "[ " <> D.dullyellow "\"Alice\""
4384− , ", \"Bob\""
4455+ , ", " <> D.dullyellow "\"Bob\""
4385− , ", \"Chuck\""
4456+ , ", " <> D.dullyellow "\"Chuck\""
4386 , "]"
4457 , "]"
4387 ]
4458 ]
4388 , D.reflow $
4459 , D.reflow $
@@ -4440,9 +4511,9 @@ toListReport source context list startRow startCol =
4440 "I may be confused by indentation. For example, if you are trying to define\
4511 "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:"
4512 \ a list across multiple lines, I recommend using this format:"
4442 , D.indent 4 $ D.vcat $
4513 , D.indent 4 $ D.vcat $
4443− [ "[ \"Alice\""
4514+ [ "[ " <> D.dullyellow "\"Alice\""
4444− , ", \"Bob\""
4515+ , ", " <> D.dullyellow "\"Bob\""
4445− , ", \"Chuck\""
4516+ , ", " <> D.dullyellow "\"Chuck\""
4446 , "]"
4517 , "]"
4447 ]
4518 ]
4448 , D.reflow $
4519 , D.reflow $
@@ -4471,9 +4542,9 @@ toListReport source context list startRow startCol =
4471 "I may be confused by indentation. For example, if you are trying to define\
4542 "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:"
4543 \ a list across multiple lines, I recommend using this format:"
4473 , D.indent 4 $ D.vcat $
4544 , D.indent 4 $ D.vcat $
4474− [ "[ \"Alice\""
4545+ [ "[ " <> D.dullyellow "\"Alice\""
4475− , ", \"Bob\""
4546+ , ", " <> D.dullyellow "\"Bob\""
4476− , ", \"Chuck\""
4547+ , ", " <> D.dullyellow "\"Chuck\""
4477 , "]"
4548 , "]"
4478 ]
4549 ]
4479 , D.reflow $
4550 , D.reflow $
@@ -4499,9 +4570,9 @@ toListReport source context list startRow startCol =
4499 , D.toSimpleNote
4570 , D.toSimpleNote
4500 "I recommend using the following format for lists that span multiple lines:"
4571 "I recommend using the following format for lists that span multiple lines:"
4501 , D.indent 4 $ D.vcat $
4572 , D.indent 4 $ D.vcat $
4502− [ "[ \"Alice\""
4573+ [ "[ " <> D.dullyellow "\"Alice\""
4503− , ", \"Bob\""
4574+ , ", " <> D.dullyellow "\"Bob\""
4504− , ", \"Chuck\""
4575+ , ", " <> D.dullyellow "\"Chuck\""
4505 , "]"
4576 , "]"
4506 ]
4577 ]
4507 , D.reflow $
4578 , D.reflow $