@@ -368,9 +368,9 @@ data Pattern
368 | PChar Char Row Col
368 | PChar Char Row Col
369 | PString String Row Col
369 | PString String Row Col
370 | PNumber Number Row Col
370 | PNumber Number Row Col
371− | PFloat Int Row Col
371+ | PFloat Word16 Row Col
372 | PAlias Row Col
372 | PAlias Row Col
373− | PWildcardNotVar Int Row Col
373+ | PWildcardNotVar Name.Name Int Row Col
374 | PSpace Space Row Col
374 | PSpace Space Row Col
376 | PIndentStart Row Col
376 | PIndentStart Row Col
@@ -394,9 +394,9 @@ data PTuple
394 | PTupleExpr Pattern Row Col
394 | PTupleExpr Pattern Row Col
395 | PTupleSpace Space Row Col
395 | PTupleSpace Space Row Col
397− | PTupleIndentOpen Row Col
398 | PTupleIndentEnd Row Col
397 | PTupleIndentEnd Row Col
399− | PTupleIndentExpr Row Col
398+ | PTupleIndentExpr1 Row Col
399+ | PTupleIndentExprN Row Col
402data PList
402data PList
@@ -508,8 +508,8 @@ toReport source err =
509 [ D.reflow $
509 [ D.reflow $
510 "I need the module name to be declared at the top of this file, like this:"
510 "I need the module name to be declared at the top of this file, like this:"
511− , D.indent 4 $ D.green $ D.fromChars $
511+ , D.indent 4 $ D.fillSep $
512− "module " ++ ModuleName.toChars name ++ " exposing (..)"
512+ [ D.cyan "module", D.fromName name, D.cyan "exposing", "(..)" ]
513 , D.reflow $
513 , D.reflow $
514 "Try adding that as the first line of your file!"
514 "Try adding that as the first line of your file!"
515 , D.toSimpleNote $
515 , D.toSimpleNote $
@@ -550,7 +550,7 @@ toReport source err =
552 [ D.fillSep
552 [ D.fillSep
553− ["Switch","this","to","say",D.green "port module","instead,"
553+ ["Switch","this","to","say",D.cyan "port module","instead,"
554 ,"marking","that","this","module","contains","port","declarations."
554 ,"marking","that","this","module","contains","port","declarations."
556 , D.link "Note"
556 , D.link "Note"
@@ -568,7 +568,7 @@ toReport source err =
568 "This module does not declare any ports, but it says it will:"
568 "This module does not declare any ports, but it says it will:"
570 D.fillSep
570 D.fillSep
571− ["Switch","this","to",D.green "module"
571+ ["Switch","this","to",D.cyan "module"
572 ,"and","you","should","be","all","set!"
572 ,"and","you","should","be","all","set!"
@@ -989,13 +989,77 @@ toDeclDefReport source name declDef startRow startCol =
989 toSpaceReport source space row col
989 toSpaceReport source space row col
991 DeclDefEquals row col ->
991 DeclDefEquals row col ->
992− error "TODO DeclDefEquals" row col
992+ case Code.whatIsNext source row col of
993+ Code.Keyword keyword ->
995+ surroundings = A.Region (A.Position startRow startCol) (A.Position row col)
996+ region = toWiderRegion row col (fromIntegral (length keyword))
998+ Report.Report "RESERVED WORD" region [] $
999+ Code.toSnippet source surroundings (Just region)
1002+ "It looks like you are trying to use `" ++ keyword ++ "` as an argument:"
1005+ "This is a reserved word! Try using some other name?"
1008+ Code.Operator op ->
1010+ surroundings = A.Region (A.Position startRow startCol) (A.Position row col)
1011+ region = toWiderRegion row col (fromIntegral (length op))
1013+ Report.Report "UNEXPECTED SYMBOL" region [] $
1014+ Code.toSnippet source surroundings (Just region)
1017+ "I was not expecting to see this symbol here:"
1021+ "I am not sure what is going wrong exactly, so here is a valid\
1022+ \ definition (with an optional type annotation) for reference:"
1024+ [ D.fillSep [D.green "add",":","Int","->","Int","->","Int"]
1025+ , D.fillSep [D.green "add","x","y","="]
1026+ , D.fillSep [" ","x","+","y"]
1029+ "Try to use that format with your `" ++ Name.toChars name ++ "` definition!"
1035+ surroundings = A.Region (A.Position startRow startCol) (A.Position row col)
1036+ region = toRegion row col
1038+ Report.Report "PROBLEM IN DEFINITION" region [] $
1039+ Code.toSnippet source surroundings (Just region)
1042+ "I got stuck while parsing the `" ++ Name.toChars name ++ "` definition:"
1046+ "I am not sure what is going wrong exactly, so here is a valid\
1047+ \ definition (with an optional type annotation) for reference:"
1049+ [ D.fillSep [D.green "add",":","Int","->","Int","->","Int"]
1050+ , D.fillSep [D.green "add","x","y","="]
1051+ , D.fillSep [" ","x","+","y"]
1054+ "Try to use that format!"
994 DeclDefType tipe row col ->
1058 DeclDefType tipe row col ->
995− error "TODO DeclDefType" tipe row col
1059+ error "TODO DeclDefType" toTypeReport tipe row col
997 DeclDefArg pattern row col ->
1061 DeclDefArg pattern row col ->
998− error "TODO DeclDefArg" pattern row col
1062+ toPatternReport source PArg pattern row col
1000 DeclDefBody expr row col ->
1064 DeclDefBody expr row col ->
1001 toExprReport source (InDef name startRow startCol) expr row col
1065 toExprReport source (InDef name startRow startCol) expr row col
@@ -1092,8 +1156,8 @@ isWithin desiredNode context =
1092toExprReport :: Code.Source -> Context -> Expr -> Row -> Col -> Report.Report
1156toExprReport :: Code.Source -> Context -> Expr -> Row -> Col -> Report.Report
1093toExprReport source context expr startRow startCol =
1157toExprReport source context expr startRow startCol =
1094 case expr of
1158 case expr of
1095− Let _ _ _ ->
1159+ Let let_ row col ->
1096− error "TODO Let"
1160+ toLetReport source context let_ row col
1098 Case case_ row col ->
1162 Case case_ row col ->
1099 toCaseReport source context case_ row col
1163 toCaseReport source context case_ row col
@@ -1692,6 +1756,145 @@ toOperatorReport source context operator row col =
1762+toLetReport :: Code.Source -> Context -> Let -> Row -> Col -> Report.Report
1763+toLetReport source context let_ startRow startCol =
1765+ LetSpace space row col ->
1766+ toSpaceReport source space row col
1770+ surroundings = A.Region (A.Position startRow startCol) (A.Position row col)
1771+ region = toRegion row col
1773+ Report.Report "LET PROBLEM" region [] $
1774+ Code.toSnippet source surroundings (Just region)
1777+ "I was partway through parsing a `let` expression, but I got stuck here:"
1781+ ["Based","on","the","indentation,","I","was","expecting","to","see","the",D.cyan "in"
1782+ ,"keyword","next.","Is","there","a","typo?"
1785+ "This can also happen if you are trying to define another value within the `let` but\
1786+ \ it is not indented enough. Make sure each definition has exactly the same amount of\
1787+ \ spaces before it. They should line up exactly!"
1791+ LetDefAlignment _ row col ->
1793+ surroundings = A.Region (A.Position startRow startCol) (A.Position row col)
1794+ region = toRegion row col
1796+ Report.Report "LET PROBLEM" region [] $
1797+ Code.toSnippet source surroundings (Just region)
1800+ "I was partway through parsing a `let` expression, but I got stuck here:"
1804+ ["Based","on","the","indentation,","I","was","expecting","to","see","the",D.cyan "in"
1805+ ,"keyword","next.","Is","there","a","typo?"
1808+ "This can also happen if you are trying to define another value within the `let` but\
1809+ \ it is not indented enough. Make sure each definition has exactly the same amount of\
1810+ \ spaces before it. The should line up exactly!"
1814+ LetDefName row col ->
1815+ case Code.whatIsNext source row col of
1816+ Code.Keyword keyword ->
1818+ surroundings = A.Region (A.Position startRow startCol) (A.Position row col)
1819+ region = toWiderRegion row col (fromIntegral (length keyword))
1821+ Report.Report "RESERVED WORD" region [] $
1822+ Code.toSnippet source surroundings (Just region)
1825+ "I was partway through parsing a `let` expression, but I got stuck here:"
1828+ "It looks like you are trying to use `" ++ keyword ++ "` as a variable name, but\
1829+ \ it is a reserved word! Try using a different name instead."
1833+ toUnfinishLetReport source row col startRow startCol $
1835+ "I was expecting the name of a definition next."
1837+ LetDef name def row col ->
1838+ error "TODO LetDef" name def row col
1840+ LetDestruct destruct row col ->
1841+ error "TODO LetDestruct" destruct row col
1843+ LetBody expr row col ->
1844+ toExprReport source context expr row col
1846+ LetIndentDef row col ->
1847+ toUnfinishLetReport source row col startRow startCol $
1849+ "I was expecting a value to be defined here."
1851+ LetIndentIn row col ->
1852+ toUnfinishLetReport source row col startRow startCol $
1854+ ["I","was","expecting","to","see","the",D.cyan "in","keyword","next."
1855+ ,"Or","maybe","more","of","that","expression?"
1858+ LetIndentBody row col ->
1859+ toUnfinishLetReport source row col startRow startCol $
1861+ "I was expecting an expression next. Tell me what should happen with the value you just defined!"
1864+toUnfinishLetReport :: Code.Source -> Row -> Col -> Row -> Col -> D.Doc -> Report.Report
1865+toUnfinishLetReport source row col startRow startCol message =
1867+ surroundings = A.Region (A.Position startRow startCol) (A.Position row col)
1868+ region = toRegion row col
1870+ Report.Report "UNFINISHED LET" region [] $
1871+ Code.toSnippet source surroundings (Just region)
1874+ "I was partway through parsing a `let` expression, but I got stuck here:"
1879+ "Here is an example with a valid `let` expression for reference:"
1881+ [ D.indent 0 $ D.fillSep [D.green "viewPerson","person","="]
1882+ , D.indent 2 $ D.fillSep [D.cyan "let"]
1883+ , D.indent 4 $ D.fillSep ["fullName","="]
1884+ , D.indent 6 $ D.fillSep ["person.firstName","++",D.dullyellow "\" \"","++","person.lastName"]
1885+ , D.indent 2 $ D.fillSep [D.cyan "in"]
1886+ , D.indent 2 $ D.fillSep ["div","[]","[","text","fullName","]"]
1889+ "Here we defined a `viewPerson` function that turns a person into some HTML. We use\
1890+ \ a `let` expression to define the `fullName` we want to show. Notice the indentation! The\
1891+ \ `fullName` is indented more than the `let` keyword, and the actual value of `fullName` is\
1892+ \ indented a bit more than that. That is important!"
@@ -1706,7 +1909,7 @@ toCaseReport source context case_ startRow startCol =
1706 D.fillSep ["I","was","expecting","to","see","the",D.dullyellow "of","keyword","next."]
1909 D.fillSep ["I","was","expecting","to","see","the",D.dullyellow "of","keyword","next."]
1708 CasePattern pattern row col ->
1911 CasePattern pattern row col ->
1709− error "TODO CasePattern" pattern row col
1912+ toPatternReport source PCase pattern row col
1711 CaseArrow row col ->
1914 CaseArrow row col ->
@@ -1819,10 +2022,10 @@ toUnfinishCaseReport source row col startRow startCol message =
1819 , D.vcat $
2022 , D.vcat $
1820 [ D.indent 4 $ D.fillSep [D.cyan "case","maybeWidth",D.cyan "of"]
2023 [ D.indent 4 $ D.fillSep [D.cyan "case","maybeWidth",D.cyan "of"]
1821 , D.indent 6 $ D.fillSep [D.green "Just","width","->"]
2024 , D.indent 6 $ D.fillSep [D.green "Just","width","->"]
1822− , D.indent 8 $ D.fillSep ["width","+",D.yellow "200"]
2025+ , D.indent 8 $ D.fillSep ["width","+",D.dullyellow "200"]
1824 , D.indent 6 $ D.fillSep [D.green "Nothing","->"]
2027 , D.indent 6 $ D.fillSep [D.green "Nothing","->"]
1825− , D.indent 8 $ D.fillSep [D.yellow "400"]
2028+ , D.indent 8 $ D.fillSep [D.dullyellow "400"]
1827 , D.reflow $
2030 , D.reflow $
1828 "Notice the indentation. Each pattern is aligned, and each branch is indented\
2031 "Notice the indentation. Each pattern is aligned, and each branch is indented\
@@ -1842,10 +2045,10 @@ addNoteForCaseIndentError message =
1842 , D.vcat $
2045 , D.vcat $
1843 [ D.indent 4 $ D.fillSep [D.cyan "case","maybeWidth",D.cyan "of"]
2046 [ D.indent 4 $ D.fillSep [D.cyan "case","maybeWidth",D.cyan "of"]
1844 , D.indent 6 $ D.fillSep [D.green "Just","width","->"]
2047 , D.indent 6 $ D.fillSep [D.green "Just","width","->"]
1845− , D.indent 8 $ D.fillSep ["width","+",D.yellow "200"]
2048+ , D.indent 8 $ D.fillSep ["width","+",D.dullyellow "200"]
1847 , D.indent 6 $ D.fillSep [D.green "Nothing","->"]
2050 , D.indent 6 $ D.fillSep [D.green "Nothing","->"]
1848− , D.indent 8 $ D.fillSep [D.yellow "400"]
2051+ , D.indent 8 $ D.fillSep [D.dullyellow "400"]
1850 , D.reflow $
2053 , D.reflow $
1851 "Notice the indentation! Each pattern is aligned, and each branch is indented\
2054 "Notice the indentation! Each pattern is aligned, and each branch is indented\
@@ -1875,7 +2078,7 @@ toIfReport source context if_ startRow startCol =
1875 "I was expecting to see more of this `if` expression, but I got stuck here:"
2078 "I was expecting to see more of this `if` expression, but I got stuck here:"
1877 D.fillSep $
2080 D.fillSep $
1878− ["I","was","expecting","to","see","the",D.green "then","keyword","next."
2081+ ["I","was","expecting","to","see","the",D.cyan "then","keyword","next."
@@ -1891,7 +2094,7 @@ toIfReport source context if_ startRow startCol =
1891 "I was expecting to see more of this `if` expression, but I got stuck here:"
2094 "I was expecting to see more of this `if` expression, but I got stuck here:"
1893 D.fillSep $
2096 D.fillSep $
1894− ["I","was","expecting","to","see","the",D.green "else","keyword","next."
2097+ ["I","was","expecting","to","see","the",D.cyan "else","keyword","next."
@@ -1953,7 +2156,7 @@ toIfReport source context if_ startRow startCol =
1955 [ D.fillSep $
2158 [ D.fillSep $
1956− ["I","was","expecting","to","see","the",D.green "then","keyword","next."
2159+ ["I","was","expecting","to","see","the",D.cyan "then","keyword","next."
1958 , D.toSimpleNote $
2161 , D.toSimpleNote $
1959 "I can be confused by indentation. Maybe something is not indented enough?"
2162 "I can be confused by indentation. Maybe something is not indented enough?"
@@ -2015,7 +2218,7 @@ toIfReport source context if_ startRow startCol =
2015 [ D.reflow $
2218 [ D.reflow $
2016 "I know what to do when the condition is `True`, but not when it is `False`."
2219 "I know what to do when the condition is `True`, but not when it is `False`."
2017 , D.fillSep
2220 , D.fillSep
2018− ["Add","an",D.green "else","branch","to","handle","that","scenario!"]
2221+ ["Add","an",D.cyan "else","branch","to","handle","that","scenario!"]
@@ -2594,7 +2797,7 @@ toFuncReport source context func startRow startCol =
2594 toSpaceReport source space row col
2797 toSpaceReport source space row col
2596 FuncArg pattern row col ->
2799 FuncArg pattern row col ->
2597− error "TODO FuncArg" pattern row col
2800+ toPatternReport source PArg pattern row col
2599 FuncBody expr row col ->
2802 FuncBody expr row col ->
2600 toExprReport source (InNode NFunc startRow startCol context) expr row col
2803 toExprReport source (InNode NFunc startRow startCol context) expr row col
@@ -2706,80 +2909,418 @@ toFuncReport source context func startRow startCol =
2920+toPatternReport :: Code.Source -> PContext -> Pattern -> Row -> Col -> Report.Report
2921+toPatternReport source context pattern startRow startCol =
2711− case err of
2922+ case pattern of
2712− CommentOnNothing region ->
2923+ PRecord record row col ->
2924+ toPRecordReport source record row col
2926+ PTuple tuple row col ->
2927+ toPTupleReport source context tuple row col
2929+ PList list row col ->
2930+ toPListReport source context list row col
2933+ case Code.whatIsNext source row col of
2934+ Code.Keyword keyword ->
2936+ surroundings = A.Region (A.Position startRow startCol) (A.Position row col)
2937+ region = toWiderRegion row col (fromIntegral (length keyword))
2940+ PArg -> "an argument"
2941+ PCase -> "a pattern"
2943+ Report.Report "RESERVED WORD" region [] $
2944+ Code.toSnippet source surroundings (Just region)
2947+ "It looks like you are trying to use `" ++ keyword ++ "` as " ++ aThing ++ ":"
2950+ "This is a reserved word! Try using some other name?"
2954+ error "TODO PStart"
2956+ PChar char row col ->
2957+ toCharReport source char row col
2959+ PString string row col ->
2960+ toStringReport source string row col
2962+ PNumber number row col ->
2963+ toNumberReport source number row col
2965+ PFloat width row col ->
2967+ region = toWiderRegion row col width
2713− Report.Report "STRAY COMMENT" region [] $
2969+ Report.Report "UNEXPECTED PATTERN" region [] $
2714 Code.toSnippet source region Nothing
2970 Code.toSnippet source region Nothing
2716− "This documentation comment is not followed by anything."
2718 D.reflow $
2972 D.reflow $
2719− "All documentation comments need to be right above the declaration they\
2973+ "I cannot pattern match with floating point numbers:"
2720− \ describe. Maybe some code got deleted or commented out by accident? Or\
2974+ ,
2721− \ maybe this comment is here by accident?"
2975+ D.fillSep $
2976+ ["Equality","on","floats","can","be","unreliable,","so","you","usually","want"
2977+ ,"to","check","that","they","are","nearby","with","some","sort","of"
2978+ ,D.dullyellow "(abs (actual - expected) < 0.001)","check."
2724− ParseError row col context expectation ->
2982+ PAlias row col ->
2983+ error "TODO PAlias" row col
2985+ PWildcardNotVar name width row col ->
2726− pos = A.Position row col
2987+ region = toWiderRegion row col (fromIntegral width)
2727− region = A.Region pos pos
2988+ examples =
2989+ case dropWhile (=='_') (Name.toChars name) of
2990+ [] -> [D.dullyellow "x","or",D.dullyellow "age"]
2991+ c:cs -> [D.dullyellow (D.fromChars (Char.toLower c : cs))]
2729− case expectation of
2993+ Report.Report "UNEXPECTED NAME" region [] $
2994+ Code.toSnippet source region Nothing $
2997+ "Variable names cannot start with underscores like this:"
3000+ ["You","can","either","have","an","underscore","like",D.dullyellow "_","to"
3001+ ,"ignore","the","value,","or","you","can","have","a","name","like"
3002+ ] ++ examples ++ ["to","use","the","matched","value." ]
2731− DocComment ->
3005+ PSpace space row col ->
2732− Report.Report "EXPECTING DOC COMMENT" region [] $
3006+ toSpaceReport source space row col
2733− Code.toSnippet source region Nothing
2736− "I was expecting a doc comment here:"
2739− "Check out" "TODO" "for examples of doc comments."
2742− -- Parse.Number
3008+ PIndentStart row col ->
3009+ error "TODO PIndentStart" row col
2744− Wildcard ->
3011+ PIndentAlias row col ->
2745− Report.Report "EXPECTING A WILDCARD" region [] $
3012+ error "TODO PIndentAlias" row col
3015+toPRecordReport :: Code.Source -> PRecord -> Row -> Col -> Report.Report
3016+toPRecordReport source record startRow startCol =
3018+ PRecordOpen row col ->
3019+ toUnfinishRecordPatternReport source row col startRow startCol $
3020+ D.reflow "I was expecting to see a field name next."
3022+ PRecordEnd row col ->
3023+ toUnfinishRecordPatternReport source row col startRow startCol $
3025+ ["I","was","expecting","to","see","a","closing","curly","brace","next."
3026+ ,"Try","adding","a",D.dullyellow "}","here?"
3029+ PRecordField row col ->
3030+ case Code.whatIsNext source row col of
3031+ Code.Keyword keyword ->
3033+ surroundings = A.Region (A.Position startRow startCol) (A.Position row col)
3034+ region = toWiderRegion row col (fromIntegral (length keyword))
3036+ Report.Report "RESERVED WORD" region [] $
2746− Code.toSnippet source region Nothing
3037+ Code.toSnippet source surroundings (Just region)
2748 D.reflow $
3039 D.reflow $
2749− "I was expecting a _ here:"
3040+ "I was not expecting to see `" ++ keyword ++ "` as a record field name:"
2751 D.reflow $
3042 D.reflow $
2752− "An underscore indicates that “I do not care about this value” and is\
3043+ "This is a reserved word, not available for variable names. Try another name!"
2753− \ called a wildcard pattern because it will match with any type of values."
2756− WildcardNotVar startCol endCol ->
3046+ _ ->
3047+ toUnfinishRecordPatternReport source row col startRow startCol $
3048+ D.reflow "I was expecting to see a field name next."
3050+ PRecordSpace space row col ->
3051+ toSpaceReport source space row col
3053+ PRecordIndentOpen row col ->
3054+ toUnfinishRecordPatternReport source row col startRow startCol $
3055+ D.reflow "I was expecting to see a field name next."
3057+ PRecordIndentEnd row col ->
3058+ toUnfinishRecordPatternReport source row col startRow startCol $
3060+ ["I","was","expecting","to","see","a","closing","curly","brace","next."
3061+ ,"Try","adding","a",D.dullyellow "}","here?"
3064+ PRecordIndentField row col ->
3065+ toUnfinishRecordPatternReport source row col startRow startCol $
3066+ D.reflow "I was expecting to see a field name next."
3069+toUnfinishRecordPatternReport :: Code.Source -> Row -> Col -> Row -> Col -> D.Doc -> Report.Report
3070+toUnfinishRecordPatternReport source row col startRow startCol message =
3072+ surroundings = A.Region (A.Position startRow startCol) (A.Position row col)
3073+ region = toRegion row col
3075+ Report.Report "UNFINISHED RECORD PATTERN" region [] $
3076+ Code.toSnippet source surroundings (Just region)
3079+ "I was partway through parsing a record pattern, but I got stuck here:"
3084+ ["A","record","pattern","looks","like",D.dullyellow "{x,y}","or",D.dullyellow "{name,age}"
3085+ ,"where","you","list","the","field","names","you","want","to","access."
3092+toPTupleReport :: Code.Source -> PContext -> PTuple -> Row -> Col -> Report.Report
3093+toPTupleReport source context tuple startRow startCol =
3095+ PTupleOpen row col ->
3096+ case Code.whatIsNext source row col of
3097+ Code.Keyword keyword ->
2759− A.Region (A.Position row startCol) (A.Position row endCol)
3099+ surroundings = A.Region (A.Position startRow startCol) (A.Position row col)
3100+ region = toWiderRegion row col (fromIntegral (length keyword))
2761− Report.Report "INVALID PATTERN" badRegion [] $
3102+ Report.Report "RESERVED WORD" region [] $
2762− Code.toSnippet source badRegion Nothing
3103+ Code.toSnippet source surroundings (Just region)
2764 D.reflow $
3105 D.reflow $
2765− "I was expecting to see an underscore without any additional characters:"
3106+ "It looks like you are trying to use `" ++ keyword ++ "` as a variable name:"
2767 D.reflow $
3108 D.reflow $
2768− "There are two options. Either (1) remove the extra characters and ignore the\
3109+ "This is a reserved word! Try using some other name?"
2769− \ value or (2) remove the starting underscore to give the value a normal name."
2772− -- Parse.Pattern
3112+ _ ->
2774− FloatInPattern ->
3114+ surroundings = A.Region (A.Position startRow startCol) (A.Position row col)
3115+ region = toRegion row col
2775− Report.Report "INVALID PATTERN" region [] $
3117+ Report.Report "UNFINISHED PARENTHESES" region [] $
2776− Code.toSnippet source region Nothing
3118+ Code.toSnippet source surroundings (Just region)
2778 D.reflow $
3120 D.reflow $
2779− "I cannot pattern match with floating point numbers:"
3121+ "I just saw an open parenthesis, but I got stuck here:"
2781− D.reflow $
3123+ D.fillSep
2782− "Equality on floats can be unreliable, so you usually want to check that they\
3124+ ["I","was","expecting","so","see","a","pattern","next."
2783− \ are nearby with some sort of (abs (actual - expected) < 0.001) check."
3125+ ,"Maybe","it","will","end","up","being","something"
3126+ ,"like",D.dullyellow "(x,y)","or",D.dullyellow "(name, _)" <> "?"
3130+ PTupleEnd row col ->
3132+ surroundings = A.Region (A.Position startRow startCol) (A.Position row col)
3133+ region = toRegion row col
3135+ Report.Report "UNFINISHED PARENTHESES" region [] $
3136+ Code.toSnippet source surroundings (Just region) $
3139+ "I was expecting a closing parenthesis next:"
3141+ D.fillSep ["Try","adding","a",D.dullyellow ")","to","see","if","that","helps?"]
3144+ PTupleExpr pattern row col ->
3145+ toPatternReport source context pattern row col
3147+ PTupleSpace space row col ->
3148+ toSpaceReport source space row col
3150+ PTupleIndentEnd row col ->
3152+ surroundings = A.Region (A.Position startRow startCol) (A.Position row col)
3153+ region = toRegion row col
3155+ Report.Report "UNFINISHED PARENTHESES" region [] $
3156+ Code.toSnippet source surroundings (Just region) $
3159+ "I was expecting a closing parenthesis next:"
3162+ [ D.fillSep ["Try","adding","a",D.dullyellow ")","to","see","if","that","helps?"]
3164+ "I can get confused by indentation in cases like this, so\
3165+ \ maybe you have a closing parenthesis but it is not indented enough?"
3169+ PTupleIndentExpr1 row col ->
3171+ surroundings = A.Region (A.Position startRow startCol) (A.Position row col)
3172+ region = toRegion row col
3174+ Report.Report "UNFINISHED PARENTHESES" region [] $
3175+ Code.toSnippet source surroundings (Just region) $
3178+ "I just saw an open parenthesis, but then I got stuck here:"
3181+ ["I","was","expecting","so","see","a","pattern","next."
3182+ ,"Maybe","it","will","end","up","being","something"
3183+ ,"like",D.dullyellow "(x,y)","or",D.dullyellow "(name, _)" <> "?"
3187+ PTupleIndentExprN row col ->
3189+ surroundings = A.Region (A.Position startRow startCol) (A.Position row col)
3190+ region = toRegion row col
3192+ Report.Report "UNFINISHED TUPLE" region [] $
3193+ Code.toSnippet source surroundings (Just region) $
3196+ "I am partway through parsing a tuple pattern, but I got stuck here:"
3200+ ["I","was","expecting","so","see","a","pattern","next."
3201+ ,"I","am","expecting","the","final","result","to","be","something"
3202+ ,"like",D.dullyellow "(x,y)","or",D.dullyellow "(name, _)" <> "."
3205+ "I can get confused by indentation in cases like this, so the problem\
3206+ \ may be that the next part is not indented enough?"
3211+toPListReport :: Code.Source -> PContext -> PList -> Row -> Col -> Report.Report
3212+toPListReport source context list startRow startCol =
3214+ PListOpen row col ->
3215+ error "TODO PListOpen" row col startRow startCol
3217+ PListEnd row col ->
3218+ error "TODO PListEnd" row col
3220+ PListExpr pattern row col ->
3221+ toPatternReport source context pattern row col
3223+ PListSpace space row col ->
3224+ toSpaceReport source space row col
3226+ PListIndentOpen row col ->
3227+ error "TODO PListIndentOpen" row col
3229+ PListIndentEnd row col ->
3230+ error "TODO PListIndentEnd" row col
3232+ PListIndentExpr row col ->
3233+ error "TODO PListIndentExpr" row col
3240+toTypeReport :: Code.Source -> Type -> Row -> Col -> Report.Report
3241+toTypeReport source tipe startRow startCol =
3243+ TRecord record row col ->
3244+ toTRecordReport source record row col
3246+ TTuple tuple row col ->
3247+ toTTupleReport source tuple row col
3249+ TVariant row col ->
3250+ error "TODO TVariant" row col startRow startCol
3253+ error "TODO TArrow" row col
3256+ error "TODO TStart" row col
3258+ TSpace space row col ->
3259+ toSpaceReport source space row col
3261+ TIndentStart row col ->
3262+ error "TODO TIndentStart" row col
3266+toTRecordReport :: Code.Source -> TRecord -> Row -> Col -> Report.Report
3267+toTRecordReport source record startRow startCol =
3269+ TRecordOpen row col ->
3270+ error "TODO TRecordOpen" row col startRow startCol
3272+ TRecordEnd row col ->
3273+ error "TODO TRecordEnd" row col
3275+ TRecordField row col ->
3276+ error "TODO TRecordField" row col
3278+ TRecordColon row col ->
3279+ error "TODO TRecordColon" row col
3281+ TRecordType tipe row col ->
3282+ error "TODO TRecordType" tipe row col
3284+ TRecordSpace space row col ->
3285+ toSpaceReport source space row col
3287+ TRecordIndentOpen row col ->
3288+ error "TODO TRecordIndentOpen" row col
3290+ TRecordIndentField row col ->
3291+ error "TODO TRecordIndentField" row col
3293+ TRecordIndentColon row col ->
3294+ error "TODO TRecordIndentColon" row col
3296+ TRecordIndentType row col ->
3297+ error "TODO TRecordIndentType" row col
3299+ TRecordIndentEnd row col ->
3300+ error "TODO TRecordIndentEnd" row col
3304+toTTupleReport :: Code.Source -> TTuple -> Row -> Col -> Report.Report
3305+toTTupleReport source tuple startRow startCol =
3307+ TTupleOpen row col ->
3308+ error "TODO TTupleOpen" row col startRow startCol
3310+ TTupleEnd row col ->
3311+ error "TODO TTupleEnd" row col
3313+ TTupleType tipe row col ->
3314+ error "TODO TTupleType" tipe row col
3316+ TTupleSpace space row col ->
3317+ toSpaceReport source space row col
3319+ TTupleIndentOpen row col ->
3320+ error "TODO TTupleIndentOpen" row col
3322+ TTupleIndentType row col ->
3323+ error "TODO TTupleIndentType" row col
3325+ TTupleIndentEnd row col ->
3326+ error "TODO TTupleIndentEnd" row col