@@ -20,8 +20,10 @@ module Reporting.Error.Type
22import Prelude hiding (round)
22import Prelude hiding (round)
23+import qualified Data.Map as Map
23import Data.Monoid ((<>))
24import Data.Monoid ((<>))
26+import qualified AST.Canonical as Can
25import qualified Data.Index as Index
27import qualified Data.Index as Index
26import qualified Elm.Name as N
28import qualified Elm.Name as N
27import qualified Reporting.Doc as D
29import qualified Reporting.Doc as D
@@ -63,9 +65,8 @@ data Context
63 | CaseBranch Index.ZeroBased
65 | CaseBranch Index.ZeroBased
64 | CallArity MaybeName Int
66 | CallArity MaybeName Int
65 | CallArg MaybeName Index.ZeroBased
67 | CallArg MaybeName Index.ZeroBased
66− | TooManyArgs MaybeName Int
67 | RecordAccess N.Name
68 | RecordAccess N.Name
68− | RecordUpdate
69+ | RecordUpdate N.Name (Map.Map N.Name Can.Expr)
69 | Destructure
70 | Destructure
@@ -185,36 +186,26 @@ toPatternReport source localizer patternRegion category tipe expected =
185 case expected of
186 case expected of
186 PNoExpectation expectedType ->
187 PNoExpectation expectedType ->
187 Report.toCodeSnippet source patternRegion Nothing $
188 Report.toCodeSnippet source patternRegion Nothing $
189− "This pattern is being used in an unexpected way:"
189+ ( "This pattern is being used in an unexpected way:"
191− patternTypeComparison localizer tipe expectedType
190+ , patternTypeComparison localizer tipe expectedType
192− (
191+ (addPatternCategory "It is" category)
193− toPatternDescription category "It is"
195− "But it needs to match values of type:"
192+ (singular "But it needs to match")
201 PFromContext region context expectedType ->
196 PFromContext region context expectedType ->
202 Report.toCodeSnippet source region (Just patternRegion) $
197 Report.toCodeSnippet source region (Just patternRegion) $
203 case context of
198 case context of
204 PTypedArg name index ->
199 PTypedArg name index ->
206− D.reflow $
200+ ( D.reflow $
207− "The " <> D.ordinalize (Index.toHuman index) <> " argument to `" <> N.toString name <> "` is weird."
201+ "The " <> D.ordinal index <> " argument to `" <> N.toString name <> "` is weird."
209− patternTypeComparison localizer tipe expectedType
202+ , patternTypeComparison localizer tipe expectedType
211− toPatternDescription category $
212− "The argument is a pattern that matches"
203+ (addPatternCategory "The argument is a pattern that matches" category)
214− "But the type annotation on `" <> N.toString name <> "` says the " <> D.ordinalize (Index.toHuman index) <> " argument should be:"
205+ "But the type annotation on `" <> N.toString name
215− ,
206+ <> "` says the " <> D.ordinal index <> " argument should be"
220 PCaseMatch index ->
211 PCaseMatch index ->
@@ -224,82 +215,58 @@ toPatternReport source localizer patternRegion category tipe expected =
224 "The 1st pattern in this `case` causing a mismatch:"
215 "The 1st pattern in this `case` causing a mismatch:"
226 patternTypeComparison localizer tipe expectedType
217 patternTypeComparison localizer tipe expectedType
228− toPatternDescription category "The first pattern is trying to match"
218+ (addPatternCategory "The first pattern is trying to match" category)
229− ,
219+ (singular "But the expression between `case` and `of` is")
230− "But it is supposed to match an expression of type:"
232− [ D.reflow $
220+ [ D.reflow $
233− "Is the pattern the problem? Or is it the expression you are trying to match on?"
221+ "These can never match! Is the pattern the problem? Or is it the expression?"
239− D.reflow $
225+ ( D.reflow $
240− "The " <> D.ordinalize (Index.toHuman index) <> " pattern in this `case` does not match the previous ones."
226+ "The " <> D.ordinal index <> " pattern in this `case` does not match the previous ones."
242− patternTypeComparison localizer tipe expectedType
227+ , patternTypeComparison localizer tipe expectedType
244− toPatternDescription category $
245− "The " <> D.ordinalize (Index.toHuman index) <> " pattern is trying to match"
228+ (addPatternCategory ("The " <> D.ordinal index <> " pattern is trying to match") category)
247− "But all the previous patterns match values of type:"
229+ (plural "But all the previous patterns match")
248− ,
230+ [ D.link "Note"
231+ "A `case` expression can only handle one type of value, so you may want to use"
233+ "to handle “mixing” types."
253 PCtorArg name index ->
237 PCtorArg name index ->
255− D.reflow $
238+ ( D.reflow $
256− "The " <> D.ordinalize (Index.toHuman index) <> " argument to `" <> N.toString name <> "` is weird."
239+ "The " <> D.ordinal index <> " argument to `" <> N.toString name <> "` is weird."
258− patternTypeComparison localizer tipe expectedType
240+ , patternTypeComparison localizer tipe expectedType
259− (
241+ (addPatternCategory "It is trying to match" category)
260− toPatternDescription category "It is trying to match"
242+ (singular $
262− "But `" <> N.toString name <> "` needs its " <> D.ordinalize (Index.toHuman index) <> " argument to be:"
243+ "But `" <> N.toString name <> "` needs its "
263− ,
244+ <> D.ordinal index <> " argument to be"
268 PListEntry index ->
249 PListEntry index ->
270− D.reflow $
250+ ( D.reflow $
271− "The " <> D.ordinalize (Index.toHuman index) <> " pattern in this list does not match all the previous ones:"
251+ "The " <> D.ordinal index <> " pattern in this list does not match all the previous ones:"
273− patternTypeComparison localizer tipe expectedType
252+ , patternTypeComparison localizer tipe expectedType
275− toPatternDescription category $
276− "The " <> D.ordinalize (Index.toHuman index) <> " pattern is trying to match"
253+ (addPatternCategory ("The " <> D.ordinal index <> " pattern is trying to match") category)
278− "But all the previous patterns in the list are:"
254+ (plural "But all the previous patterns in the list are")
280− [ D.toSimpleHint $
255+ [ D.toSimpleHint $
281− "Everything in the list needs to be the same type of value.\
256+ "Everything in the list needs to be the same type of value.\
282− \ This way you never run into unexpected values partway through.\
257+ \ This way you never run into unexpected values partway through.\
283− \ To mix different types in a single list, create a \"union type\" as\
258+ \ To mix different types in a single list, create a \"union type\" as\
284− \ described in: <http://guide.elm-lang.org/types/union_types.html>"
259+ \ described in: <http://guide.elm-lang.org/types/union_types.html>"
291− D.reflow $
264+ ( D.reflow $
292 "The pattern after (::) is causing issues."
265 "The pattern after (::) is causing issues."
294− patternTypeComparison localizer tipe expectedType
266+ , patternTypeComparison localizer tipe expectedType
296− toPatternDescription category $
297− "The pattern after (::) is trying to match"
267+ (addPatternCategory "The pattern after (::) is trying to match" category)
299− "But it needs to match lists like this:"
268+ (\_ -> "But it needs to match lists like this:")
@@ -307,96 +274,144 @@ toPatternReport source localizer patternRegion category tipe expected =
307-- PATTERN HELPERS
274-- PATTERN HELPERS
310−patternTypeComparison :: L.Localizer -> T.Type -> T.Type -> ( String, String, [D.Doc] ) -> D.Doc
277+patternTypeComparison
281+ -> (Maybe N.Name -> D.Doc)
282+ -> (Maybe N.Name -> D.Doc)
311−patternTypeComparison localizer actual expected ( iAmSeeing, insteadOf, contextHints ) =
285+patternTypeComparison localizer actual expected iAmSeeing insteadOf contextHints =
313− (actualDoc, expectedDoc, problems) =
287+ (T.Comparison actualAlias actualDoc expectedAlias expectedDoc problems) =
314− T.toDiffDocs localizer actual expected
288+ T.toComparison localizer actual expected
316 D.stack $
290 D.stack $
317− [ D.reflow iAmSeeing
291+ [ iAmSeeing actualAlias
318 , D.indent 4 actualDoc
292 , D.indent 4 actualDoc
319− , D.reflow insteadOf
293+ , insteadOf expectedAlias
320 , D.indent 4 expectedDoc
294 , D.indent 4 expectedDoc
322 ++ problemsToHint problems
296 ++ problemsToHint problems
323 ++ contextHints
297 ++ contextHints
326−toPatternDescription :: PCategory -> String -> String
300+addPatternCategory :: String -> PCategory -> Maybe N.Name -> D.Doc
327−toPatternDescription category iAmTryingToMatch =
301+addPatternCategory iAmTryingToMatch category maybeAlias =
328− iAmTryingToMatch <>
302+ D.reflow $ iAmTryingToMatch <>
305+ " `" <> N.toString alias <> "` values:"
329− case category of
308+ case category of
330− PRecord -> " record values of type:"
309+ PRecord -> " record values of type:"
331− PUnit -> " unit values:"
310+ PUnit -> " unit values:"
332− PTuple -> " tuples of type:"
311+ PTuple -> " tuples of type:"
333− PList -> " lists of type:"
312+ PList -> " lists of type:"
334− PCtor name -> " `" <> N.toString name <> "` values of type:"
313+ PCtor name -> " `" <> N.toString name <> "` values of type:"
335− PInt -> " integers:"
314+ PInt -> " integers:"
336− PStr -> " strings:"
315+ PStr -> " strings:"
337− PChr -> " characters:"
316+ PChr -> " characters:"
341-- EXPR HELPERS
320-- EXPR HELPERS
344−typeComparison :: L.Localizer -> T.Type -> T.Type -> ( String, String, [D.Doc] ) -> D.Doc
323+typeComparison
327+ -> (Maybe N.Name -> D.Doc)
328+ -> (Maybe N.Name -> D.Doc)
345−typeComparison localizer actual expected ( iAmSeeing, insteadOf, contextHints ) =
331+typeComparison localizer actual expected iAmSeeing insteadOf contextHints =
347− (actualDoc, expectedDoc, problems) =
333+ (T.Comparison actualAlias actualDoc expectedAlias expectedDoc problems) =
348− T.toDiffDocs localizer actual expected
334+ T.toComparison localizer actual expected
350 D.stack $
336 D.stack $
351− [ D.reflow iAmSeeing
337+ [ iAmSeeing actualAlias
352 , D.indent 4 actualDoc
338 , D.indent 4 actualDoc
353− , D.reflow insteadOf
339+ , insteadOf expectedAlias
354 , D.indent 4 expectedDoc
340 , D.indent 4 expectedDoc
356 ++ problemsToHint problems
342 ++ problemsToHint problems
357 ++ contextHints
343 ++ contextHints
360−loneType :: L.Localizer -> T.Type -> T.Type -> ( D.Doc, [D.Doc] ) -> D.Doc
347+ :: L.Localizer
350+ -> (Maybe N.Name -> D.Doc)
361−loneType localizer actual expected ( iAmSeeing, furtherDetails ) =
353+loneType localizer actual expected iAmSeeing furtherDetails =
363− (actualDoc, _, problems) =
355+ (T.Comparison actualAlias actualDoc _ _ problems) =
364− T.toDiffDocs localizer actual expected
356+ T.toComparison localizer actual expected
366 D.stack $
358 D.stack $
367− [ iAmSeeing
359+ [ iAmSeeing actualAlias
368 , D.indent 4 actualDoc
360 , D.indent 4 actualDoc
370 ++ furtherDetails
362 ++ furtherDetails
371 ++ problemsToHint problems
363 ++ problemsToHint problems
374−toDescription :: Category -> String -> String
366+singular :: String -> Maybe N.Name -> D.Doc
375−toDescription category thatThingIs =
367+singular insteadOf maybeAlias =
368+ D.reflow $ insteadOf <>
371+ Just a -> " a `" <> N.toString a <> "` value:"
374+plural :: String -> Maybe N.Name -> D.Doc
375+plural insteadOf maybeAlias =
376+ D.reflow $ insteadOf <>
379+ Just a -> " `" <> N.toString a <> "` values:"
382+addCategory :: String -> Category -> Maybe N.Name -> D.Doc
383+addCategory thisIs category maybeAlias =
385+ definitely whatever =
387+ Just alias -> " a `" <> N.toString alias <> "` value:"
376 case category of
391 case category of
377− Local name -> "This `" <> N.toString name <> "` value has type:"
392+ Local name -> "This `" <> N.toString name <> "` value is" <> definitely " a:"
378− Foreign name -> "This `" <> N.toString name <> "` value has type:"
393+ Foreign name -> "This `" <> N.toString name <> "` value is" <> definitely " a:"
379− Access field -> "The value at ." <> N.toString field <> " has type:"
394+ Access field -> "The value at ." <> N.toString field <> " is" <> definitely " a:"
380 Accessor field -> "This ." <> N.toString field <> " field access function has type:"
395 Accessor field -> "This ." <> N.toString field <> " field access function has type:"
381− If -> "This `if` expression produces a value of type:"
396+ If -> "This `if` expression produces" <> definitely ":"
382− Case -> "This `case` expression produces a value of type:"
397+ Case -> "This `case` expression produces" <> definitely ":"
383− List -> thatThingIs <> " a list of type:"
398+ List -> thisIs <> definitely " a list of type:"
384− Number -> thatThingIs <> " a number of type:"
399+ Number -> thisIs <> definitely " a number of type:"
385− Float -> thatThingIs <> " a float of type:"
400+ Float -> thisIs <> definitely " a float of type:"
386− String -> thatThingIs <> " a string of type:"
401+ String -> thisIs <> definitely " a string of type:"
387− Char -> thatThingIs <> " a character of type:"
402+ Char -> thisIs <> definitely " a character of type:"
388− Lambda -> thatThingIs <> " an anonymous function of type:"
403+ Lambda -> thisIs <> definitely " an anonymous function of type:"
389− Record -> thatThingIs <> " a record of type:"
404+ Record -> thisIs <> definitely " a record of type:"
390− Tuple -> thatThingIs <> " a tuple of type:"
405+ Tuple -> thisIs <> definitely " a tuple of type:"
391− Unit -> thatThingIs <> " a unit value:"
406+ Unit -> thisIs <> definitely " a unit value:"
392− Shader -> thatThingIs <> " a GLSL shader of type:"
407+ Shader -> thisIs <> definitely " a GLSL shader of type:"
393− Effects -> thatThingIs <> " a thing for CORE LIBRARIES ONLY."
408+ Effects -> thisIs <> " a thing for CORE LIBRARIES ONLY."
394 CallResult maybeName ->
409 CallResult maybeName ->
395 case maybeName of
410 case maybeName of
396− NoName -> thatThingIs <> ":"
411+ NoName -> thisIs <> ":"
397− FuncName name -> "This `" <> N.toString name <> "` call produces:"
412+ FuncName name -> "This `" <> N.toString name <> "` call produces" <> definitely ":"
398− CtorName name -> "This `" <> N.toString name <> "` call produces:"
413+ CtorName name -> "This `" <> N.toString name <> "` call produces" <> definitely ":"
399− OpName _ -> thatThingIs <> ":"
414+ OpName _ -> thisIs <> definitely ":"
402problemsToHint :: [T.Problem] -> [D.Doc]
417problemsToHint :: [T.Problem] -> [D.Doc]
@@ -637,203 +652,171 @@ badFlexFlexSuper s1 s2 =
638toExprReport :: Code.Source -> L.Localizer -> R.Region -> Category -> T.Type -> Expected T.Type -> Report.Report
653toExprReport :: Code.Source -> L.Localizer -> R.Region -> Category -> T.Type -> Expected T.Type -> Report.Report
639toExprReport source localizer exprRegion category tipe expected =
654toExprReport source localizer exprRegion category tipe expected =
640− Report.Report "TYPE MISMATCH" exprRegion [] $
641 case expected of
655 case expected of
642 NoExpectation expectedType ->
656 NoExpectation expectedType ->
657+ Report.Report "TYPE MISMATCH" exprRegion [] $
643− Report.toCodeSnippet source exprRegion Nothing
658+ Report.toCodeSnippet source exprRegion Nothing
645− "This expression is being used in an unexpected way:"
659+ ( "This expression is being used in an unexpected way:"
647− typeComparison localizer tipe expectedType
660+ , typeComparison localizer tipe expectedType
648− (
661+ (addCategory "It is" category)
649− toDescription category "It is"
651− "But you are trying to use it as:"
662+ (singular "But you are trying to use it as")
657 FromAnnotation name _arity subContext expectedType ->
666 FromAnnotation name _arity subContext expectedType ->
670+ TypedIfBranch index -> D.ordinal index <> " branch of this `if` expression:"
671+ TypedCaseBranch index -> D.ordinal index <> " branch of this `case` expression:"
672+ TypedBody -> "body of the `" <> N.toString name <> "` definition:"
676+ TypedIfBranch index -> "The " <> D.ordinal index <> " branch is"
677+ TypedCaseBranch index -> "The " <> D.ordinal index <> " branch is"
678+ TypedBody -> "The body is"
680+ Report.Report "TYPE MISMATCH" exprRegion [] $
658− Report.toCodeSnippet source exprRegion Nothing
681+ Report.toCodeSnippet source exprRegion Nothing $
659− (
682+ ( D.reflow ("Something is off with the " <> thing)
662− TypedIfBranch index ->
663− "Something is off with the " <> D.ordinalize (Index.toHuman index) <> " branch of this `if` expression:"
665− TypedCaseBranch index ->
666− "Something is off with the " <> D.ordinalize (Index.toHuman index) <> " branch of this `case` expression:"
669− "Something is off with the body of the `" <> N.toString name <> "` definition:"
671− typeComparison localizer tipe expectedType
683+ , typeComparison localizer tipe expectedType
672− (
684+ (addCategory itIs category)
673− toDescription category $
675− TypedIfBranch index ->
676− "The " <> D.ordinalize (Index.toHuman index) <> " branch is"
678− TypedCaseBranch index ->
679− "The " <> D.ordinalize (Index.toHuman index) <> " branch is"
684− "But the type annotation on `" <> N.toString name <> "` says it should be:"
685+ (singular $ "But the type annotation on `" <> N.toString name <> "` says it should be")
690 FromContext region context expectedType ->
689 FromContext region context expectedType ->
691+ mismatch (maybeHighlight, problem, thisIs, insteadOf, furtherDetails) =
692+ Report.Report "TYPE MISMATCH" exprRegion [] $
693+ Report.toCodeSnippet source region maybeHighlight
695+ , typeComparison localizer tipe expectedType (addCategory thisIs category) insteadOf furtherDetails
698+ badType (maybeHighlight, problem, thisIs, furtherDetails) =
699+ Report.Report "TYPE MISMATCH" exprRegion [] $
700+ Report.toCodeSnippet source region maybeHighlight
702+ , loneType localizer tipe expectedType (addCategory thisIs category) furtherDetails
691 case context of
705 case context of
692 ListEntry index ->
706 ListEntry index ->
707+ let ith = D.ordinal index in
693− Report.toCodeSnippet source region (Just exprRegion)
709+ ( Just exprRegion
696− "The " <> D.ordinalize (Index.toHuman index) <> " element of this list does not match all the previous elements:"
710+ , "The " <> ith <> " element of this list does not match all the previous elements:"
698− typeComparison localizer tipe expectedType
700− toDescription category $
701− "The " <> D.ordinalize (Index.toHuman index) <> " element is"
711+ , "The " <> ith <> " element is"
703− "But all the previous elements in the list are:"
712+ , plural "But all the previous elements in the list are"
705− [ D.toSimpleHint $
713+ , [ D.toSimpleHint $
706− "Everything in the list needs to be the same type of value.\
714+ "Everything in the list needs to be the same type of value.\
707− \ This way you never run into unexpected values partway through.\
715+ \ This way you never run into unexpected values partway through.\
708− \ To mix different types in a single list, create a \"union type\" as\
716+ \ To mix different types in a single list, create a \"union type\" as\
709− \ described in: <http://guide.elm-lang.org/types/union_types.html>"
717+ \ described in: <http://guide.elm-lang.org/types/union_types.html>"
714 Negate ->
721 Negate ->
715− Report.toCodeSnippet source region (Just exprRegion)
723+ ( Just exprRegion
717− "I do not know how to negate this type of value:"
724+ , "I do not know how to negate this type of value:"
719− loneType localizer tipe expectedType
721− D.reflow $ toDescription category "It is"
723− [ D.fillSep
726+ , [ D.fillSep
724− ["But","I","only","now","how","to","negate"
727+ ["But","I","only","now","how","to","negate"
725− ,D.dullyellow "Int","and",D.dullyellow "Float","values."
728+ ,D.dullyellow "Int","and",D.dullyellow "Float","values."
731 OpLeft op ->
733 OpLeft op ->
734+ Report.Report "TYPE MISMATCH" exprRegion [] $
732− Report.toCodeSnippet source region (Just exprRegion) $
735+ Report.toCodeSnippet source region (Just exprRegion) $
733− opLeftToDocs localizer category op tipe expectedType
736+ opLeftToDocs localizer category op tipe expectedType
735 OpRight op ->
738 OpRight op ->
739+ Report.Report "TYPE MISMATCH" exprRegion [] $
736− case opRightToDocs localizer category op tipe expectedType of
740+ case opRightToDocs localizer category op tipe expectedType of
737− EmphBoth details ->
741+ EmphBoth details ->
738− Report.toCodeSnippet source region Nothing details
742+ Report.toCodeSnippet source region Nothing details
740− EmphRight details ->
744+ EmphRight details ->
741− Report.toCodeSnippet source region (Just exprRegion) details
745+ Report.toCodeSnippet source region (Just exprRegion) details
743 IfCondition ->
747 IfCondition ->
744− Report.toCodeSnippet source region (Just exprRegion)
749+ ( Just exprRegion
746− "This `if` condition does not evaluate to a boolean value, True or False."
750+ , "This `if` condition does not evaluate to a boolean value, True or False."
748− loneType localizer tipe expectedType
750− D.reflow $ toDescription category "It is"
752− [ D.fillSep ["But","I","need","this","`if`","condition","to","be","a",D.dullyellow "Bool","value."]
752+ , [ D.fillSep ["But","I","need","this","`if`","condition","to","be","a",D.dullyellow "Bool","value."]
757 IfBranch index ->
756 IfBranch index ->
757+ let ith = D.ordinal index in
758− Report.toCodeSnippet source region (Just exprRegion)
759+ ( Just exprRegion
761− "The " <> D.ordinalize (Index.toHuman index) <> " branch of this `if` does not match all the previous branches:"
760+ , "The " <> ith <> " branch of this `if` does not match all the previous branches:"
763− typeComparison localizer tipe expectedType
765− toDescription category $
766− "The " <> D.ordinalize (Index.toHuman index) <> " branch is"
761+ , "The " <> ith <> " branch is"
768− "But all the previous branches result in:"
762+ , plural "But all the previous branches result in"
770− [ D.link "Hint"
763+ , [ D.link "Hint"
771− "All branches in an `if` must produce the same type of values. This way, no\
764+ "All branches in an `if` must produce the same type of values. This way, no\
772− \ matter which branch we take, the result is always a consistent shape. Read"
765+ \ matter which branch we take, the result is always a consistent shape. Read"
773− "union-types"
766+ "union-types"
774− "to learn how to “mix” types."
767+ "to learn how to “mix” types."
779 CaseBranch index ->
771 CaseBranch index ->
772+ let ith = D.ordinal index in
780− Report.toCodeSnippet source region (Just exprRegion)
774+ ( Just exprRegion
783− "The " <> D.ordinalize (Index.toHuman index) <> " branch of this `case` does not match all the previous branches:"
775+ , "The " <> ith <> " branch of this `case` does not match all the previous branches:"
785− typeComparison localizer tipe expectedType
787− toDescription category $
788− "The " <> D.ordinalize (Index.toHuman index) <> " branch is"
776+ , "The " <> ith <> " branch is"
790− "But all the previous branches result in:"
777+ , plural "But all the previous branches result in"
792− [ D.link "Hint"
778+ , [ D.link "Hint"
793− "All branches in a `case` must produce the same type of values. This way, no\
779+ "All branches in a `case` must produce the same type of values. This way, no\
794− \ matter which branch we take, the result is always a consistent shape. Read"
780+ \ matter which branch we take, the result is always a consistent shape. Read"
795− "union-types"
781+ "union-types"
796− "to learn how to “mix” types."
782+ "to learn how to “mix” types."
801− CallArity maybeFuncName numArgs ->
786+ CallArity maybeFuncName numGivenArgs ->
787+ Report.Report "TOO MANY ARGS" exprRegion [] $
788+ Report.toCodeSnippet source region (Just exprRegion) $
802 case countArgs tipe of
789 case countArgs tipe of
804− Report.toCodeSnippet source region (Just exprRegion)
791+ let
805− ( D.reflow $
792+ thisValue =
806− case maybeFuncName of
793+ case maybeFuncName of
807− NoName -> "This is not a function:"
794+ NoName -> "This value"
808− FuncName name -> "The `" <> N.toString name <> "` value is not a function:"
795+ FuncName name -> "The `" <> N.toString name <> "` value"
809− CtorName name -> "The `" <> N.toString name <> "` value is not a function:"
796+ CtorName name -> "The `" <> N.toString name <> "` value"
810− OpName op -> "The (" <> N.toString op <> ") operator is not a function:"
797+ OpName op -> "The (" <> N.toString op <> ") operator"
812− D.stack $
799+ ( D.reflow $ thisValue <> " is not a function, but it was given " <> D.args numGivenArgs <> "."
813− [ "It has type:"
800+ , D.reflow $ "Are there any missing commas? Or missing parentheses?"
814− , D.indent 4 $ D.dullyellow $ T.toDoc localizer RT.None tipe
815− , D.reflow $ "So it cannot accept arguments, but it got " <> show numArgs <> " anyway."
820− Report.toCodeSnippet source region (Just exprRegion)
804+ let
821− ( D.reflow $
805+ thisFunction =
822− case maybeFuncName of
806+ case maybeFuncName of
823− NoName -> "This function was given too many arguments:"
807+ NoName -> "This function"
824− FuncName name -> "The `" <> N.toString name <> "` function was given too many arguments:"
808+ FuncName name -> "The `" <> N.toString name <> "` function"
825− CtorName name -> "The `" <> N.toString name <> "` constructor was given too many arguments:"
809+ CtorName name -> "The `" <> N.toString name <> "` constructor"
826− OpName op -> "The (" <> N.toString op <> ") operator was given too many arguments:"
810+ OpName op -> "The (" <> N.toString op <> ") operator"
830− , D.indent 4 $ D.dullyellow $ T.toDoc localizer RT.None tipe
831− , D.reflow $ "So it expects " <> D.args n <> ", but it got " <> show numArgs <> " instead."
812+ ( D.reflow $ thisFunction <> " expects " <> D.args n <> ", but it got " <> show numGivenArgs <> " instead."
832− ]
813+ , D.reflow $ "Are there any missing commas? Or missing parentheses?"
835 CallArg maybeFuncName index ->
816 CallArg maybeFuncName index ->
818+ ith = D.ordinal index
837 thisFunction =
820 thisFunction =
838 case maybeFuncName of
821 case maybeFuncName of
839 NoName -> "this function"
822 NoName -> "this function"
@@ -841,187 +824,81 @@ toExprReport source localizer exprRegion category tipe expected =
841 CtorName name -> "`" <> N.toString name <> "`"
824 CtorName name -> "`" <> N.toString name <> "`"
842 OpName op -> "(" <> N.toString op <> ")"
825 OpName op -> "(" <> N.toString op <> ")"
844− Report.toCodeSnippet source region (Just exprRegion)
828+ ( Just exprRegion
847− "The " <> D.ordinalize (Index.toHuman index) <> " argument to " <> thisFunction <> " is not what I expect:"
829+ , "The " <> ith <> " argument to " <> thisFunction <> " is not what I expect:"
849− typeComparison localizer tipe expectedType
851− toDescription category "This argument is"
830+ , "This argument is"
853− "But " <> thisFunction <> " needs the " <> D.ordinalize (Index.toHuman index)
831+ , singular $ "But " <> thisFunction <> " needs the " <> ith <> " argument to be"
854− <> " argument to be:"
856− if Index.toHuman index == 1 then
833+ if Index.toHuman index == 1 then
859− [ D.toSimpleHint $
836+ [ D.toSimpleHint $
860− "I always figure out the argument types from left to right. If an argument\
837+ "I always figure out the argument types from left to right. If an argument\
861− \ is acceptable, I assume it is “correct” and move on. So the problem may\
838+ \ is acceptable, I assume it is “correct” and move on. So the problem may\
862− \ actually be in one of the previous arguments!"
839+ \ actually be in one of the previous arguments!"
867− TooManyArgs maybeName numGivenArgs ->
868− case countArgs tipe of
870− Report.toCodeSnippet source region (Just exprRegion)
875− "You are giving " <> D.args numGivenArgs <> " to something that is not a function!"
878− "`" <> N.toString name <> "` is not a function, but you are giving it " <> D.args numGivenArgs <> "!"
881− "`" <> N.toString name <> "` is not a function, but you are giving it " <> D.args numGivenArgs <> "!"
884− "(" <> N.toString op <> ") is not a function, but you are giving it " <> D.args numGivenArgs <> "!"
886− typeComparison localizer tipe expectedType
890− "It is a value of type:"
893− "`" <> N.toString name <> "` is a value of type:"
896− "`" <> N.toString name <> "` is a constructor of type:"
899− "(" <> N.toString op <> ") is a value of type:"
901− "But you are giving it " <> D.args numGivenArgs <> " as if its type was:"
903− [ "Maybe you forgot some parentheses? Or a comma?"
916− "The `" <> N.toString name <> "` function"
919− "The `" <> N.toString name <> "` constructor"
922− "The (" <> N.toString op <> ") function"
924− Report.toCodeSnippet source region (Just exprRegion)
927− thisFunction <> " is getting too many arguments:"
929− typeComparison localizer tipe expectedType
931− thisFunction <> " is expecting to get " <> D.args numExpectedArgs <> " like this:"
933− "But you are giving it " <> D.args numGivenArgs <> " as if its type was:"
935− [ "Maybe you forgot some parentheses? Or a comma?"
937− "I am not good at figuring out which arguments are extra myself. The\
938− \ problem may even be that the FUNCTION is defined funny, and the arguments are\
939− \ actually fine. Anyway, I hope I gave enough info to help you figure it out!"
944 RecordAccess field ->
843 RecordAccess field ->
945− Report.toCodeSnippet source region (Just exprRegion) $
844+ badType $
946− case tipe of
845+ case T.getFields tipe of
947− T.Record _ _ ->
846+ Just _fields ->
948− (
847+ ( Just exprRegion
950− "This record does not have a `" <> N.toString field <> "` field:"
848+ , "This record does not have a `" <> N.toString field <> "` field:"
952− loneType localizer tipe expectedType
850+ , [ -- TODO suggest what the typo is!
954− D.reflow $ "It is a record with this type:"
957− ["Is","the",D.dullyellow ("." <> D.fromName field)
958− ,"field","access","is","misspelled?"
965− (
855+ ( Just exprRegion
967− "This is not a record, so it has no fields to access!"
856+ , "This is not a record, so it has no fields to access!"
969− loneType localizer tipe expectedType
970− ( D.reflow $ toDescription category "It is"
971− , [ D.fillSep
858+ , [ D.fillSep
972− ["But","I","need","a","record","with","a"
859+ ["But","I","need","a","record","with","a"
973− ,D.dullyellow (D.fromName field),"field!"
860+ ,D.dullyellow (D.fromName field),"field!"
979− RecordUpdate ->
865+ RecordUpdate name updatedFields ->
980− case T.iteratedDealias tipe of
867+ case T.getFields tipe of
981− T.Record _ _ ->
868+ Nothing ->
982− Report.toCodeSnippet source region Nothing $
869+ ( Just exprRegion
983− (
870+ , "I cannot update the `" <> N.toString name <> "` value:"
984− D.reflow $
871+ , "It is"
985− "I think there is a typo in one of these field names:"
872+ , [ D.reflow $ "It is not a record. It has no fields to update!"
987− typeComparison localizer tipe expectedType
989− "The record you want to update has type:"
991− "But you are saying it should have these fields:"
993− [ D.reflow "Maybe there is some typo?"
998− _ ->
876+ Just _fields ->
999− Report.toCodeSnippet source region (Just exprRegion)
877+ case Map.keys updatedFields of
1001− "The record update syntax does not work with this value:"
879+ ( Nothing
1002− ,
880+ , "The `" <> N.toString name <> "` record does not have a `" <> N.toString field <> "` field."
1003− loneType localizer tipe expectedType
881+ , "It is"
1004− ( D.reflow $ toDescription category "It is"
882+ , [ -- TODO suggest what the typo is!
1005− , [ D.reflow $ "But I need some kind of record here!"
883+ ]
888+ , "The `" <> N.toString name <> "` record does have all of these fields:"
890+ , [ -- TODO suggest what the typo is!
1010 Destructure ->
894 Destructure ->
1011− Report.toCodeSnippet source region Nothing
895+ mismatch
1013− D.reflow $
897+ , "This definition is causing issues:"
1014− "I cannot destructure "
1016− typeComparison localizer tipe expectedType
1018− toDescription category "You are defining"
898+ , "You are defining"
1020− "But then trying to destructure it as:"
899+ , singular "But then trying to destructure it as"
@@ -1069,27 +946,19 @@ opLeftToDocs localizer category op tipe expected =
1071 ( "The left side of (<|) needs to be a function so I can pipe arguments to it!"
948 ( "The left side of (<|) needs to be a function so I can pipe arguments to it!"
1073− loneType localizer tipe expected
949+ , loneType localizer tipe expected
1074− ( D.reflow $ toDescription category "I am seeing"
950+ (addCategory "I am seeing" category)
1075− , [ D.reflow $ "This needs to be some kind of function though!"
951+ [ D.reflow $ "This needs to be some kind of function though!"
1082− D.reflow $
956+ ( D.reflow $
1083 "The left argument of (" <> N.toString op <> ") is causing problems:"
957 "The left argument of (" <> N.toString op <> ") is causing problems:"
1085− typeComparison localizer tipe expected
958+ , typeComparison localizer tipe expected
1087− toDescription category "The left argument is"
959+ (addCategory "The left argument is" category)
1089− "But (" <> N.toString op <> ") needs the left argument to be:"
960+ (singular $ "But (" <> N.toString op <> ") needs the left argument to be")
@@ -1146,47 +1015,30 @@ opRightToDocs localizer category op tipe expected =
1148 EmphRight
1017 EmphRight
1151− "I cannot send this through the (<|) pipe:"
1018+ ( D.reflow $ "I cannot send this through the (<|) pipe:"
1153− typeComparison localizer tipe expected
1019+ , typeComparison localizer tipe expected
1155− toDescription category "You are providing"
1020+ (addCategory "You are providing" category)
1157− "But (<|) is piping it a function that expects:"
1021+ (singular "But (<|) is piping it a function that expects")
1164 case (tipe, expected) of
1026 case (tipe, expected) of
1165 (T.Lambda expectedArgType _ _, T.Lambda argType _ _) ->
1027 (T.Lambda expectedArgType _ _, T.Lambda argType _ _) ->
1166 EmphRight
1028 EmphRight
1168− "This function cannot handle the argument sent through the (|>) pipe:"
1029+ ( D.reflow $ "This function cannot handle the argument sent through the (|>) pipe:"
1170− typeComparison localizer argType expectedArgType
1030+ , typeComparison localizer argType expectedArgType
1171− (
1031+ (addCategory "The argument is" category)
1172− "You are providing an argument of type:"
1174− "But (|>) is piping it a function that expects its next argument to be:"
1032+ (singular "But (|>) is piping it a function that expects")
1181 EmphRight
1037 EmphRight
1183− "The right side of (|>) needs to be a function so I can pipe arguments to it!"
1038+ ( D.reflow $ "The right side of (|>) needs to be a function so I can pipe arguments to it!"
1185− loneType localizer tipe expected
1039+ , loneType localizer tipe expected
1186− ( D.reflow $ toDescription category $
1187− "But instead of a function, I am seeing "
1040+ (addCategory "But instead of a function, I am seeing" category)
@@ -1196,22 +1048,16 @@ opRightToDocs localizer category op tipe expected =
1196badOpRightFallback :: L.Localizer -> Category -> N.Name -> T.Type -> T.Type -> RightDocs
1048badOpRightFallback :: L.Localizer -> Category -> N.Name -> T.Type -> T.Type -> RightDocs
1197badOpRightFallback localizer category op tipe expected =
1049badOpRightFallback localizer category op tipe expected =
1198 EmphRight
1050 EmphRight
1200− D.reflow $
1051+ ( D.reflow $
1201 "The right argument of (" <> N.toString op <> ") is causing problems."
1052 "The right argument of (" <> N.toString op <> ") is causing problems."
1203− typeComparison localizer tipe expected
1053+ , typeComparison localizer tipe expected
1204− (
1054+ (addCategory "The right argument is" category)
1205− toDescription category "The right argument is"
1207− "But (" <> N.toString op <> ") needs the right argument to be:"
1055+ (singular $ "But (" <> N.toString op <> ") needs the right argument to be")
1209− [ D.toSimpleHint $
1056+ [ D.toSimpleHint $
1210− "With operators like (" ++ N.toString op ++ ") I always check the left\
1057+ "With operators like (" ++ N.toString op ++ ") I always check the left\
1211− \ side first. If it seems fine, I assume it is correct and check the right\
1058+ \ side first. If it seems fine, I assume it is correct and check the right\
1212− \ side. So the problem may be in how the left and right arguments interact!"
1059+ \ side. So the problem may be in how the left and right arguments interact!"
@@ -1266,16 +1112,11 @@ badConsRight localizer category tipe expected =
1266 case expected of
1112 case expected of
1267 T.Type home2 name2 [expectedElement] | T.isList home2 name2 ->
1113 T.Type home2 name2 [expectedElement] | T.isList home2 name2 ->
1268 EmphBoth
1114 EmphBoth
1270− D.reflow "I am having trouble with this (::) operator:"
1115+ ( D.reflow "I am having trouble with this (::) operator:"
1272− typeComparison localizer expectedElement actualElement
1116+ , typeComparison localizer expectedElement actualElement
1274− "The left side of (::) is an element of type:"
1117+ (singular "The left side of (::) is")
1275− ,
1118+ (plural "But you are trying to put that into a list filled with")
1276− "But the right side is a list filled with elements of type:"
1278− case expectedElement of
1119+ ( case expectedElement of
1279 T.Type home name [_] | T.isList home name ->
1120 T.Type home name [_] | T.isList home name ->
1280 [ D.toSimpleHint
1121 [ D.toSimpleHint
1281 "Are you trying to append two lists? The (++) operator\
1122 "Are you trying to append two lists? The (++) operator\
@@ -1295,16 +1136,11 @@ badConsRight localizer category tipe expected =
1297 EmphRight
1138 EmphRight
1299− D.reflow "The (::) operator can only add elements onto lists."
1139+ ( D.reflow "The (::) operator can only add elements onto lists."
1301− loneType localizer tipe expected
1140+ , loneType localizer tipe expected
1302− (
1141+ (addCategory "The right side is" category)
1303− D.reflow $ toDescription category "The right side is"
1305− [D.fillSep ["But","(::)","needs","a",D.dullyellow "List","on","the","right."]
1142+ [D.fillSep ["But","(::)","needs","a",D.dullyellow "List","on","the","right."]
@@ -1337,13 +1173,11 @@ badAppendLeft :: L.Localizer -> Category -> T.Type -> T.Type -> (D.Doc, D.Doc)
1337badAppendLeft localizer category tipe expected =
1173badAppendLeft localizer category tipe expected =
1338 case toAppendType tipe of
1174 case toAppendType tipe of
1339 ANumber thing stringFromThing ->
1175 ANumber thing stringFromThing ->
1341− D.fillSep
1176+ ( D.fillSep
1342 ["The","(++)","operator","can","append","List","and","String"
1177 ["The","(++)","operator","can","append","List","and","String"
1343 ,"values,","but","not",D.dullyellow thing,"values","like","this:"
1178 ,"values,","but","not",D.dullyellow thing,"values","like","this:"
1346− D.fillSep
1180+ , D.fillSep
1347 ["Try","using",D.green stringFromThing,"to","turn","it","into","a","string?"
1181 ["Try","using",D.green stringFromThing,"to","turn","it","into","a","string?"
1348 ,"Or","put","it","in","[]","to","make","it","a","list?"
1182 ,"Or","put","it","in","[]","to","make","it","a","list?"
1349 ,"Or","switch","to","the","(::)","operator?"
1183 ,"Or","switch","to","the","(::)","operator?"
@@ -1351,20 +1185,16 @@ badAppendLeft localizer category tipe expected =
1355− D.reflow $
1188+ ( D.reflow $
1356 "The (++) operator cannot append this type of value:"
1189 "The (++) operator cannot append this type of value:"
1358− loneType localizer tipe expected
1190+ , loneType localizer tipe expected
1359− ( D.reflow $ toDescription category "I am seeing"
1191+ (addCategory "I am seeing" category)
1361− [ D.fillSep
1192+ [ D.fillSep
1362− ["But","the","(++)","operator","is","only","for","appending"
1193+ ["But","the","(++)","operator","is","only","for","appending"
1363− ,D.dullyellow "List","and",D.dullyellow "String","values."
1194+ ,D.dullyellow "List","and",D.dullyellow "String","values."
1364− ,"Maybe","put","this","value","in","[]","to","make","it","a","list?"
1195+ ,"Maybe","put","this","value","in","[]","to","make","it","a","list?"
@@ -1373,36 +1203,28 @@ badAppendRight localizer category tipe expected =
1373 case (toAppendType expected, toAppendType tipe) of
1203 case (toAppendType expected, toAppendType tipe) of
1374 (AString, ANumber thing stringFromThing) ->
1204 (AString, ANumber thing stringFromThing) ->
1375 EmphRight
1205 EmphRight
1377− D.fillSep
1206+ ( D.fillSep
1378 ["I","thought","I","was","appending",D.dullyellow "String","values","here,"
1207 ["I","thought","I","was","appending",D.dullyellow "String","values","here,"
1379 ,"not",D.dullyellow thing,"values","like","this:"
1208 ,"not",D.dullyellow thing,"values","like","this:"
1382− D.fillSep
1210+ , D.fillSep
1383− ["Try","using",D.green stringFromThing
1211+ ["Try","using",D.green stringFromThing,"to","turn","it","into","a","string?"]
1384− ,"to","turn","it","into","a","string?"
1388 (AList, ANumber thing _) ->
1214 (AList, ANumber thing _) ->
1389 EmphRight
1215 EmphRight
1391− D.fillSep
1216+ ( D.fillSep
1392 ["I","thought","I","was","appending",D.dullyellow "List","values","here,"
1217 ["I","thought","I","was","appending",D.dullyellow "List","values","here,"
1393 ,"not",D.dullyellow thing,"values","like","this:"
1218 ,"not",D.dullyellow thing,"values","like","this:"
1396− D.reflow "Try putting it in [] to make it a list?"
1220+ , D.reflow "Try putting it in [] to make it a list?"
1399 (AString, AList) ->
1223 (AString, AList) ->
1400 EmphBoth
1224 EmphBoth
1402− D.reflow $
1225+ ( D.reflow $
1403 "The (++) operator needs the same type of value on both sides:"
1226 "The (++) operator needs the same type of value on both sides:"
1405− D.fillSep
1227+ , D.fillSep
1406 ["I","see","a",D.dullyellow "String","on","the","left","and","a"
1228 ["I","see","a",D.dullyellow "String","on","the","left","and","a"
1407 ,D.dullyellow "List","on","the","right.","Which","should","it","be?"
1229 ,D.dullyellow "List","on","the","right.","Which","should","it","be?"
1408 ,"Does","the","string","need","[]","around","it","to","become","a","list?"
1230 ,"Does","the","string","need","[]","around","it","to","become","a","list?"
@@ -1411,11 +1233,9 @@ badAppendRight localizer category tipe expected =
1412 (AList, AString) ->
1234 (AList, AString) ->
1413 EmphBoth
1235 EmphBoth
1415− D.reflow $
1236+ ( D.reflow $
1416 "The (++) operator needs the same type of value on both sides:"
1237 "The (++) operator needs the same type of value on both sides:"
1418− D.fillSep
1238+ , D.fillSep
1419 ["I","see","a",D.dullyellow "List","on","the","left","and","a"
1239 ["I","see","a",D.dullyellow "List","on","the","left","and","a"
1420 ,D.dullyellow "String","on","the","right.","Which","should","it","be?"
1240 ,D.dullyellow "String","on","the","right.","Which","should","it","be?"
1421 ,"Does","the","string","need","[]","around","it","to","become","a","list?"
1241 ,"Does","the","string","need","[]","around","it","to","become","a","list?"
@@ -1424,19 +1244,12 @@ badAppendRight localizer category tipe expected =
1425 (_,_) ->
1245 (_,_) ->
1426 EmphBoth
1246 EmphBoth
1428− D.reflow $
1247+ ( D.reflow $
1429 "The (++) operator cannot append these two values:"
1248 "The (++) operator cannot append these two values:"
1431− typeComparison localizer expected tipe
1249+ , typeComparison localizer expected tipe
1433− "I already figured out that the left side of (++) is:"
1250+ (singular "I already figured out that the left side of (++) is")
1435− toDescription category $
1436− "But this clashes with the right side, which is"
1251+ (addCategory "But this clashes with the right side, which is" category)
@@ -1450,11 +1263,9 @@ data ThisThenThat = FloatInt | IntFloat
1450badCast :: N.Name -> ThisThenThat -> RightDocs
1263badCast :: N.Name -> ThisThenThat -> RightDocs
1451badCast op thisThenThat =
1264badCast op thisThenThat =
1452 EmphBoth
1265 EmphBoth
1454− D.reflow $
1266+ ( D.reflow $
1455 "I need both sides of (" <> N.toString op <> ") to be the exact same type. Both Int or both Float."
1267 "I need both sides of (" <> N.toString op <> ") to be the exact same type. Both Int or both Float."
1458 anInt = ["an", D.dullyellow "Int"]
1269 anInt = ["an", D.dullyellow "Int"]
1459 aFloat = ["a", D.dullyellow "Float"]
1270 aFloat = ["a", D.dullyellow "Float"]
1460 toFloat = D.green "toFloat"
1271 toFloat = D.green "toFloat"
@@ -1508,18 +1319,14 @@ badListAdd localizer category direction tipe expected =
1508 "I cannot do addition with lists:"
1319 "I cannot do addition with lists:"
1510 loneType localizer tipe expected
1321 loneType localizer tipe expected
1512− D.reflow $ toDescription category $
1513− "The " <> direction <> " side of (+) is"
1322+ (addCategory ("The " <> direction <> " side of (+) is") category)
1515− [ D.fillSep
1323+ [ D.fillSep
1516− ["But","(+)","only","works","with",D.dullyellow "Int","and",D.dullyellow "Float","values."
1324+ ["But","(+)","only","works","with",D.dullyellow "Int","and",D.dullyellow "Float","values."
1518− , D.toFancyHint
1326+ , D.toFancyHint
1519− ["Switch","to","the",D.green "(++)","operator","to","append","lists!"
1327+ ["Switch","to","the",D.green "(++)","operator","to","append","lists!"
@@ -1542,10 +1349,8 @@ badMath localizer category operation direction op tipe expected otherHints =
1542 operation ++ " does not work with this value:"
1349 operation ++ " does not work with this value:"
1544 loneType localizer tipe expected
1351 loneType localizer tipe expected
1545− ( D.reflow $ toDescription category $
1546− "The " <> direction <> " side of (" <> op <> ") is"
1352+ (addCategory ("The " <> direction <> " side of (" <> op <> ") is") category)
1548− [ D.fillSep
1353+ ( [ D.fillSep
1549 ["But","(" <> D.fromString op <> ")","only","works","with"
1354 ["But","(" <> D.fromString op <> ")","only","works","with"
1550 ,D.dullyellow "Int","and",D.dullyellow "Float","values."
1355 ,D.dullyellow "Int","and",D.dullyellow "Float","values."
@@ -1578,14 +1383,13 @@ badFDiv localizer direction tipe expected =
1580 loneType localizer tipe expected
1385 loneType localizer tipe expected
1582− D.fillSep
1387+ D.fillSep
1583− ["The",direction,"side","of","(/)","must","be","a"
1388+ ["The",direction,"side","of","(/)","must","be","a"
1584− ,D.dullyellow "Float" <> ","
1585− ,"but","instead","I","am","seeing:"
1389+ ,D.dullyellow "Float" <> ",","but","instead","I","am","seeing:"
@@ -1614,14 +1418,13 @@ badIDiv localizer direction tipe expected =
1616 loneType localizer tipe expected
1420 loneType localizer tipe expected
1618− D.fillSep
1422+ D.fillSep
1619− ["The",direction,"side","of","(//)","must","be","an"
1423+ ["The",direction,"side","of","(//)","must","be","an"
1620− ,D.dullyellow "Int" <> ","
1621− ,"but","instead","I","am","seeing:"
1424+ ,D.dullyellow "Int" <> ",","but","instead","I","am","seeing:"
@@ -1636,14 +1439,13 @@ badBool localizer op direction tipe expected =
1636 "I am struggling with this boolean operation:"
1439 "I am struggling with this boolean operation:"
1638 loneType localizer tipe expected
1441 loneType localizer tipe expected
1640− D.fillSep
1443+ D.fillSep
1641− ["Both","sides","of","(" <> op <> ")","must","be"
1444+ ["Both","sides","of","(" <> op <> ")","must","be"
1642− ,D.dullyellow "Bool","values,","but","the",direction,"side","is:"
1445+ ,D.dullyellow "Bool","values,","but","the",direction,"side","is:"
@@ -1658,23 +1460,19 @@ badCompLeft localizer category op direction tipe expected =
1658 "I cannot do a comparison with this value:"
1460 "I cannot do a comparison with this value:"
1660 loneType localizer tipe expected
1462 loneType localizer tipe expected
1662− D.reflow $ toDescription category $
1663− "The " <> direction <> " side of (" <> op <> ") is"
1463+ (addCategory ("The " <> direction <> " side of (" <> op <> ") is") category)
1665− [ D.fillSep
1464+ [ D.fillSep
1666− ["But","(" <> D.fromString op <> ")","only","works","on"
1465+ ["But","(" <> D.fromString op <> ")","only","works","on"
1667− ,D.dullyellow "Int" <> ","
1466+ ,D.dullyellow "Int" <> ","
1668− ,D.dullyellow "Float" <> ","
1467+ ,D.dullyellow "Float" <> ","
1669− ,D.dullyellow "Char" <> ","
1468+ ,D.dullyellow "Char" <> ","
1671− ,D.dullyellow "String"
1470+ ,D.dullyellow "String"
1672− ,"values.","It","can","work","on","lists","and","tuples"
1471+ ,"values.","It","can","work","on","lists","and","tuples"
1673− ,"of","comparable","values","as","well,","but","it","is"
1472+ ,"of","comparable","values","as","well,","but","it","is"
1674− ,"usually","better","to","find","a","different","path."
1473+ ,"usually","better","to","find","a","different","path."
@@ -1686,15 +1484,11 @@ badCompRight localizer op tipe expected =
1686 "I need both sides of (" <> op <> ") to be the same type:"
1484 "I need both sides of (" <> op <> ") to be the same type:"
1688 typeComparison localizer expected tipe
1486 typeComparison localizer expected tipe
1690− "The left side of is:"
1487+ (singular "The left side of is")
1692− "But the right side is:"
1488+ (singular "But the right side is")
1694− [ D.reflow $
1489+ [ D.reflow $
1695− "I cannot compare different types though! Which side of (" <> op <> ") is the problem?"
1490+ "I cannot compare different types though! Which side of (" <> op <> ") is the problem?"
@@ -1710,21 +1504,15 @@ badEquality localizer op tipe expected =
1710 "I need both sides of (" <> op <> ") to be the same type:"
1504 "I need both sides of (" <> op <> ") to be the same type:"
1712 typeComparison localizer expected tipe
1506 typeComparison localizer expected tipe
1714− "The left side of is:"
1507+ (singular "The left side of is")
1716− "But the right side is:"
1508+ (singular "But the right side is")
1718− if isFloat tipe || isFloat expected then
1509+ [ if isFloat tipe || isFloat expected then
1719− [ D.toSimpleNote $
1510+ D.toSimpleNote $
1720− "Equality on floats is not 100% reliable due to the design of IEEE 754. I\
1511+ "Equality on floats is not 100% reliable due to the design of IEEE 754. I\
1721− \ recommend a check like (abs (x - y) < 0.0001) instead."
1512+ \ recommend a check like (abs (x - y) < 0.0001) instead."
1725− "Different types can never be equal though! Which side is messed up?"
1514+ D.reflow "Different types can never be equal though! Which side is messed up?"