@@ -24,7 +24,7 @@ import Data.Monoid ((<>))
2424
2525import qualified Data.Index as Index
2626import qualified Elm.Name as N
27−import qualified Reporting.Helpers as H
27+import qualified Reporting.Doc as D
2828import qualified Reporting.Region as R
2929import qualified Reporting.Render.Code as Code
3030import qualified Reporting.Render.Type as RT
@@ -202,15 +202,15 @@ toPatternReport source localizer patternRegion category tipe expected =
202202 case context of
203203 PTypedArg name index ->
204204 (
205− H.reflow $
206− "The " <> H.ordinalize (Index.toHuman index) <> " argument to `" <> N.toString name <> "` is weird."
205+ D.reflow $
206+ "The " <> D.ordinalize (Index.toHuman index) <> " argument to `" <> N.toString name <> "` is weird."
207207 ,
208208 patternTypeComparison localizer tipe expectedType
209209 (
210210 toPatternDescription category $
211211 "The argument is a pattern that matches"
212212 ,
213− "But the type annotation on `" <> N.toString name <> "` says the " <> H.ordinalize (Index.toHuman index) <> " argument should be:"
213+ "But the type annotation on `" <> N.toString name <> "` says the " <> D.ordinalize (Index.toHuman index) <> " argument should be:"
214214 ,
215215 []
216216 )
@@ -219,7 +219,7 @@ toPatternReport source localizer patternRegion category tipe expected =
219219 PCaseMatch index ->
220220 if index == Index.first then
221221 (
222− H.reflow $
222+ D.reflow $
223223 "The 1st pattern in this `case` causing a mismatch:"
224224 ,
225225 patternTypeComparison localizer tipe expectedType
@@ -228,20 +228,20 @@ toPatternReport source localizer patternRegion category tipe expected =
228228 ,
229229 "But it is supposed to match an expression of type:"
230230 ,
231− [ H.reflow $
231+ [ D.reflow $
232232 "Is the pattern the problem? Or is it the expression you are trying to match on?"
233233 ]
234234 )
235235 )
236236 else
237237 (
238− H.reflow $
239− "The " <> H.ordinalize (Index.toHuman index) <> " pattern in this `case` does not match the previous ones."
238+ D.reflow $
239+ "The " <> D.ordinalize (Index.toHuman index) <> " pattern in this `case` does not match the previous ones."
240240 ,
241241 patternTypeComparison localizer tipe expectedType
242242 (
243243 toPatternDescription category $
244− "The " <> H.ordinalize (Index.toHuman index) <> " pattern is trying to match"
244+ "The " <> D.ordinalize (Index.toHuman index) <> " pattern is trying to match"
245245 ,
246246 "But all the previous patterns match values of type:"
247247 ,
@@ -251,14 +251,14 @@ toPatternReport source localizer patternRegion category tipe expected =
251251
252252 PCtorArg name index ->
253253 (
254− H.reflow $
255− "The " <> H.ordinalize (Index.toHuman index) <> " argument to `" <> N.toString name <> "` is weird."
254+ D.reflow $
255+ "The " <> D.ordinalize (Index.toHuman index) <> " argument to `" <> N.toString name <> "` is weird."
256256 ,
257257 patternTypeComparison localizer tipe expectedType
258258 (
259259 toPatternDescription category "It is trying to match"
260260 ,
261− "But `" <> N.toString name <> "` needs its " <> H.ordinalize (Index.toHuman index) <> " argument to be:"
261+ "But `" <> N.toString name <> "` needs its " <> D.ordinalize (Index.toHuman index) <> " argument to be:"
262262 ,
263263 []
264264 )
@@ -266,17 +266,17 @@ toPatternReport source localizer patternRegion category tipe expected =
266266
267267 PListEntry index ->
268268 (
269− H.reflow $
270− "The " <> H.ordinalize (Index.toHuman index) <> " pattern in this list does not match all the previous ones:"
269+ D.reflow $
270+ "The " <> D.ordinalize (Index.toHuman index) <> " pattern in this list does not match all the previous ones:"
271271 ,
272272 patternTypeComparison localizer tipe expectedType
273273 (
274274 toPatternDescription category $
275− "The " <> H.ordinalize (Index.toHuman index) <> " pattern is trying to match"
275+ "The " <> D.ordinalize (Index.toHuman index) <> " pattern is trying to match"
276276 ,
277277 "But all the previous patterns in the list are:"
278278 ,
279− [ H.toSimpleHint $
279+ [ D.toSimpleHint $
280280 "Everything in the list needs to be the same type of value.\
281281 \ This way you never run into unexpected values partway through.\
282282 \ To mix different types in a single list, create a \"union type\" as\
@@ -287,7 +287,7 @@ toPatternReport source localizer patternRegion category tipe expected =
287287
288288 PTail ->
289289 (
290− H.reflow $
290+ D.reflow $
291291 "The pattern after (::) is causing issues."
292292 ,
293293 patternTypeComparison localizer tipe expectedType
@@ -306,17 +306,17 @@ toPatternReport source localizer patternRegion category tipe expected =
306306-- PATTERN HELPERS
307307
308308
309−patternTypeComparison :: T.Localizer -> T.Type -> T.Type -> ( String, String, [H.Doc] ) -> H.Doc
309+patternTypeComparison :: T.Localizer -> T.Type -> T.Type -> ( String, String, [D.Doc] ) -> D.Doc
310310patternTypeComparison localizer actual expected ( iAmSeeing, insteadOf, contextHints ) =
311311 let
312312 (actualDoc, expectedDoc, problems) =
313313 T.toDiffDocs localizer actual expected
314314 in
315− H.stack $
316− [ H.reflow iAmSeeing
317− , H.indent 4 actualDoc
318− , H.reflow insteadOf
319− , H.indent 4 expectedDoc
315+ D.stack $
316+ [ D.reflow iAmSeeing
317+ , D.indent 4 actualDoc
318+ , D.reflow insteadOf
319+ , D.indent 4 expectedDoc
320320 ]
321321 ++ problemsToHint problems
322322 ++ contextHints
@@ -340,31 +340,31 @@ toPatternDescription category iAmTryingToMatch =
340340-- EXPR HELPERS
341341
342342
343−typeComparison :: T.Localizer -> T.Type -> T.Type -> ( String, String, [H.Doc] ) -> H.Doc
343+typeComparison :: T.Localizer -> T.Type -> T.Type -> ( String, String, [D.Doc] ) -> D.Doc
344344typeComparison localizer actual expected ( iAmSeeing, insteadOf, contextHints ) =
345345 let
346346 (actualDoc, expectedDoc, problems) =
347347 T.toDiffDocs localizer actual expected
348348 in
349− H.stack $
350− [ H.reflow iAmSeeing
351− , H.indent 4 actualDoc
352− , H.reflow insteadOf
353− , H.indent 4 expectedDoc
349+ D.stack $
350+ [ D.reflow iAmSeeing
351+ , D.indent 4 actualDoc
352+ , D.reflow insteadOf
353+ , D.indent 4 expectedDoc
354354 ]
355355 ++ problemsToHint problems
356356 ++ contextHints
357357
358358
359−loneType :: T.Localizer -> T.Type -> T.Type -> ( H.Doc, [H.Doc] ) -> H.Doc
359+loneType :: T.Localizer -> T.Type -> T.Type -> ( D.Doc, [D.Doc] ) -> D.Doc
360360loneType localizer actual expected ( iAmSeeing, furtherDetails ) =
361361 let
362362 (actualDoc, _, problems) =
363363 T.toDiffDocs localizer actual expected
364364 in
365− H.stack $
365+ D.stack $
366366 [ iAmSeeing
367− , H.indent 4 actualDoc
367+ , D.indent 4 actualDoc
368368 ]
369369 ++ furtherDetails
370370 ++ problemsToHint problems
@@ -398,7 +398,7 @@ toDescription category thatThingIs =
398398 OpName _ -> thatThingIs <> ":"
399399
400400
401−problemsToHint :: [T.Problem] -> [H.Doc]
401+problemsToHint :: [T.Problem] -> [D.Doc]
402402problemsToHint problems =
403403 case problems of
404404 [] ->
@@ -408,63 +408,63 @@ problemsToHint problems =
408408 problemToHint problem
409409
410410
411−problemToHint :: T.Problem -> [H.Doc]
411+problemToHint :: T.Problem -> [D.Doc]
412412problemToHint problem =
413413 case problem of
414414 T.FieldMismatch _ _ -> [] -- TODO do a better job?
415415
416416 T.IntFloat ->
417− [ H.fancyLink "Note" ["Read"] "implicit-casts"
417+ [ D.fancyLink "Note" ["Read"] "implicit-casts"
418418 ["to","learn","why","Elm","does","not","implicitly","convert"
419− ,"Ints","to","Floats.","Use",H.green "toFloat","and"
420− ,H.green "round","to","do","explicit","conversions."
419+ ,"Ints","to","Floats.","Use",D.green "toFloat","and"
420+ ,D.green "round","to","do","explicit","conversions."
421421 ]
422422 ]
423423
424424 T.StringFromInt ->
425− [ H.toFancyHint
425+ [ D.toFancyHint
426426 ["Want","to","convert","an","Int","into","a","String?"
427− ,"Use","the",H.green "String.fromInt","function!"
427+ ,"Use","the",D.green "String.fromInt","function!"
428428 ]
429429 ]
430430
431431 T.StringFromFloat ->
432− [ H.toFancyHint
432+ [ D.toFancyHint
433433 ["Want","to","convert","a","Float","into","a","String?"
434− ,"Use","the",H.green "String.fromFloat","function!"
434+ ,"Use","the",D.green "String.fromFloat","function!"
435435 ]
436436 ]
437437
438438 T.StringToInt ->
439− [ H.toFancyHint
439+ [ D.toFancyHint
440440 ["Want","to","convert","a","String","into","an","Int?"
441− ,"Use","the",H.green "String.toInt","function!"
441+ ,"Use","the",D.green "String.toInt","function!"
442442 ]
443443 ]
444444
445445 T.StringToFloat ->
446− [ H.toFancyHint
446+ [ D.toFancyHint
447447 ["Want","to","convert","a","String","into","a","Float?"
448− ,"Use","the",H.green "String.toFloat","function!"
448+ ,"Use","the",D.green "String.toFloat","function!"
449449 ]
450450 ]
451451
452452 T.AnythingToBool ->
453− [ H.toSimpleHint $
453+ [ D.toSimpleHint $
454454 "Elm does not have “truthiness” such that ints and strings and lists\
455455 \ are automatically converted to booleans. Do that conversion explicitly!"
456456 ]
457457
458458 T.AnythingFromMaybe ->
459− [ H.toFancyHint
460− ["Use",H.green "Maybe.withDefault","to","handle","possible","errors."
459+ [ D.toFancyHint
460+ ["Use",D.green "Maybe.withDefault","to","handle","possible","errors."
461461 ,"Longer","term,","it","is","usually","better","to","write","out","the"
462462 ,"full","`case`","though!"
463463 ]
464464 ]
465465
466466 T.AnythingToList ->
467− [ H.toSimpleHint "Did you forget to add [] around it?"
467+ [ D.toSimpleHint "Did you forget to add [] around it?"
468468 ]
469469
470470 T.MissingArgs _ -> []
@@ -520,25 +520,25 @@ problemToHint problem =
520520-- BAD RIGID HINTS
521521
522522
523−badRigidVar :: N.Name -> String -> [H.Doc]
523+badRigidVar :: N.Name -> String -> [D.Doc]
524524badRigidVar name aThing =
525− [ H.toSimpleHint $
525+ [ D.toSimpleHint $
526526 "Your type annotation uses type variable `" ++ N.toString name ++
527527 "` which means ANY type of value can flow through, but your code is saying it specifically wants "
528528 ++ aThing ++ ". Maybe change your type annotation to\
529529 \ be more specific? Maybe change the code to be more general?"
530− , H.reflowLink "Read" "type-annotations" "for more advice!"
530+ , D.reflowLink "Read" "type-annotations" "for more advice!"
531531 ]
532532
533533
534−badDoubleRigid :: N.Name -> N.Name -> [H.Doc]
534+badDoubleRigid :: N.Name -> N.Name -> [D.Doc]
535535badDoubleRigid x y =
536− [ H.toSimpleHint $
536+ [ D.toSimpleHint $
537537 "Your type annotation uses `" ++ N.toString x ++ "` and `" ++ N.toString y ++
538538 "` as separate type variables. Your code seems to be saying they are the\
539539 \ same though! Maybe they should be the same in your type annotation?\
540540 \ Maybe your code uses them in a weird way?"
541− , H.reflowLink "Read" "type-annotations" "for more advice!"
541+ , D.reflowLink "Read" "type-annotations" "for more advice!"
542542 ]
543543
544544
@@ -555,47 +555,47 @@ toASuperThing super =
555555-- BAD SUPER HINTS
556556
557557
558−badFlexSuper :: T.Super -> T.Type -> [H.Doc]
558+badFlexSuper :: T.Super -> T.Type -> [D.Doc]
559559badFlexSuper super tipe =
560560 case super of
561561 T.Comparable ->
562− [ H.toSimpleHint "Only ints, floats, chars, strings, lists, and tuples are comparable."
562+ [ D.toSimpleHint "Only ints, floats, chars, strings, lists, and tuples are comparable."
563563 ]
564564
565565 T.Appendable ->
566566 case tipe of
567567 T.Type home name _ | T.isInt home name ->
568− [ H.toFancyHint ["Try","using",H.green"String.fromInt","to","convert","it","to","a","string?"]
568+ [ D.toFancyHint ["Try","using",D.green"String.fromInt","to","convert","it","to","a","string?"]
569569 ]
570570
571571 T.Type home name _ | T.isFloat home name ->
572− [ H.toFancyHint ["Try","using",H.green"String.fromFloat","to","convert","it","to","a","string?"]
572+ [ D.toFancyHint ["Try","using",D.green"String.fromFloat","to","convert","it","to","a","string?"]
573573 ]
574574
575575 T.FlexSuper T.Number _ ->
576− [ H.toFancyHint ["Try","using",H.green"String.fromInt","to","convert","it","to","a","string?"]
576+ [ D.toFancyHint ["Try","using",D.green"String.fromInt","to","convert","it","to","a","string?"]
577577 ]
578578
579579 _ ->
580− [ H.toFancyHint ["Only","strings","and","lists","are","appendable.","Put","it","in",H.green "[]","to","make","it","a","list?"]
580+ [ D.toFancyHint ["Only","strings","and","lists","are","appendable.","Put","it","in",D.green "[]","to","make","it","a","list?"]
581581 ]
582582
583583 T.CompAppend ->
584− [ H.toSimpleHint "Only strings and lists are both comparable and appendable."
584+ [ D.toSimpleHint "Only strings and lists are both comparable and appendable."
585585 ]
586586
587587 T.Number ->
588588 case tipe of
589589 T.Type home name _ | T.isString home name ->
590− [ H.toFancyHint ["Try","using",H.green"String.toInt","to","convert","it","to","a","number?"]
590+ [ D.toFancyHint ["Try","using",D.green"String.toInt","to","convert","it","to","a","number?"]
591591 ]
592592
593593 _ ->
594− [ H.toFancyHint ["Only",H.green "Int","and",H.green "Float","values","work","as","numbers."]
594+ [ D.toFancyHint ["Only",D.green "Int","and",D.green "Float","values","work","as","numbers."]
595595 ]
596596
597597
598−badRigidSuper :: T.Super -> String -> [H.Doc]
598+badRigidSuper :: T.Super -> String -> [D.Doc]
599599badRigidSuper super aThing =
600600 let
601601 (superType, manyThings) =
@@ -605,16 +605,16 @@ badRigidSuper super aThing =
605605 T.Appendable -> ("appendable", "strings AND lists")
606606 T.CompAppend -> ("compappend", "strings AND lists")
607607 in
608− [ H.toSimpleHint $
608+ [ D.toSimpleHint $
609609 "The `" ++ superType ++ "` in your type annotation is saying that "
610610 ++ manyThings ++ " can flow through, but your code is saying it specifically wants "
611611 ++ aThing ++ ". Maybe change your type annotation to\
612612 \ be more specific? Maybe change the code to be more general?"
613− , H.reflowLink "Read" "type-annotations" "for more advice!"
613+ , D.reflowLink "Read" "type-annotations" "for more advice!"
614614 ]
615615
616616
617−badFlexFlexSuper :: T.Super -> T.Super -> [H.Doc]
617+badFlexFlexSuper :: T.Super -> T.Super -> [D.Doc]
618618badFlexFlexSuper s1 s2 =
619619 let
620620 likeThis super =
@@ -624,7 +624,7 @@ badFlexFlexSuper s1 s2 =
624624 T.CompAppend -> "a compappend"
625625 T.Appendable -> "appendable"
626626 in
627− [ H.toSimpleHint $
627+ [ D.toSimpleHint $
628628 "There are no values in Elm that are both"
629629 ++ likeThis s1 ++ " and " ++ likeThis s2 ++ "."
630630 ]
@@ -656,13 +656,13 @@ toExprReport source localizer exprRegion category tipe expected =
656656 FromAnnotation name _arity subContext expectedType ->
657657 Report.toCodeSnippet source exprRegion Nothing
658658 (
659− H.reflow $
659+ D.reflow $
660660 case subContext of
661661 TypedIfBranch index ->
662− "Something is off with the " <> H.ordinalize (Index.toHuman index) <> " branch of this `if` expression:"
662+ "Something is off with the " <> D.ordinalize (Index.toHuman index) <> " branch of this `if` expression:"
663663
664664 TypedCaseBranch index ->
665− "Something is off with the " <> H.ordinalize (Index.toHuman index) <> " branch of this `case` expression:"
665+ "Something is off with the " <> D.ordinalize (Index.toHuman index) <> " branch of this `case` expression:"
666666
667667 TypedBody ->
668668 "Something is off with the body of the `" <> N.toString name <> "` definition:"
@@ -672,10 +672,10 @@ toExprReport source localizer exprRegion category tipe expected =
672672 toDescription category $
673673 case subContext of
674674 TypedIfBranch index ->
675− "The " <> H.ordinalize (Index.toHuman index) <> " branch is"
675+ "The " <> D.ordinalize (Index.toHuman index) <> " branch is"
676676
677677 TypedCaseBranch index ->
678− "The " <> H.ordinalize (Index.toHuman index) <> " branch is"
678+ "The " <> D.ordinalize (Index.toHuman index) <> " branch is"
679679
680680 TypedBody ->
681681 "The body is"
@@ -691,17 +691,17 @@ toExprReport source localizer exprRegion category tipe expected =
691691 ListEntry index ->
692692 Report.toCodeSnippet source region (Just exprRegion)
693693 (
694− H.reflow $
695− "The " <> H.ordinalize (Index.toHuman index) <> " element of this list does not match all the previous elements:"
694+ D.reflow $
695+ "The " <> D.ordinalize (Index.toHuman index) <> " element of this list does not match all the previous elements:"
696696 ,
697697 typeComparison localizer tipe expectedType
698698 (
699699 toDescription category $
700− "The " <> H.ordinalize (Index.toHuman index) <> " element is"
700+ "The " <> D.ordinalize (Index.toHuman index) <> " element is"
701701 ,
702702 "But all the previous elements in the list are:"
703703 ,
704− [ H.toSimpleHint $
704+ [ D.toSimpleHint $
705705 "Everything in the list needs to be the same type of value.\
706706 \ This way you never run into unexpected values partway through.\
707707 \ To mix different types in a single list, create a \"union type\" as\
@@ -717,11 +717,11 @@ toExprReport source localizer exprRegion category tipe expected =
717717 ,
718718 loneType localizer tipe expectedType
719719 (
720− H.reflow $ toDescription category "It is"
720+ D.reflow $ toDescription category "It is"
721721 ,
722− [ H.fillSep
722+ [ D.fillSep
723723 ["But","I","only","now","how","to","negate"
724− ,H.dullyellow "Int","and",H.dullyellow "Float","values."
724+ ,D.dullyellow "Int","and",D.dullyellow "Float","values."
725725 ]
726726 ]
727727 )
@@ -746,9 +746,9 @@ toExprReport source localizer exprRegion category tipe expected =
746746 ,
747747 loneType localizer tipe expectedType
748748 (
749− H.reflow $ toDescription category "It is"
749+ D.reflow $ toDescription category "It is"
750750 ,
751− [ H.fillSep ["But","I","need","this","`if`","condition","to","be","a",H.dullyellow "Bool","value."]
751+ [ D.fillSep ["But","I","need","this","`if`","condition","to","be","a",D.dullyellow "Bool","value."]
752752 ]
753753 )
754754 )
@@ -756,17 +756,17 @@ toExprReport source localizer exprRegion category tipe expected =
756756 IfBranch index ->
757757 Report.toCodeSnippet source region (Just exprRegion)
758758 (
759− H.reflow $
760− "The " <> H.ordinalize (Index.toHuman index) <> " branch of this `if` does not match all the previous branches:"
759+ D.reflow $
760+ "The " <> D.ordinalize (Index.toHuman index) <> " branch of this `if` does not match all the previous branches:"
761761 ,
762762 typeComparison localizer tipe expectedType
763763 (
764764 toDescription category $
765− "The " <> H.ordinalize (Index.toHuman index) <> " branch is"
765+ "The " <> D.ordinalize (Index.toHuman index) <> " branch is"
766766 ,
767767 "But all the previous branches result in:"
768768 ,
769− [ H.link "Hint"
769+ [ D.link "Hint"
770770 "All branches in an `if` must produce the same type of values. This way, no\
771771 \ matter which branch we take, the result is always a consistent shape. Read"
772772 "union-types"
@@ -778,17 +778,17 @@ toExprReport source localizer exprRegion category tipe expected =
778778 CaseBranch index ->
779779 Report.toCodeSnippet source region (Just exprRegion)
780780 (
781− H.reflow $
782− "The " <> H.ordinalize (Index.toHuman index) <> " branch of this `case` does not match all the previous branches:"
781+ D.reflow $
782+ "The " <> D.ordinalize (Index.toHuman index) <> " branch of this `case` does not match all the previous branches:"
783783 ,
784784 typeComparison localizer tipe expectedType
785785 (
786786 toDescription category $
787− "The " <> H.ordinalize (Index.toHuman index) <> " branch is"
787+ "The " <> D.ordinalize (Index.toHuman index) <> " branch is"
788788 ,
789789 "But all the previous branches result in:"
790790 ,
791− [ H.link "Hint"
791+ [ D.link "Hint"
792792 "All branches in a `case` must produce the same type of values. This way, no\
793793 \ matter which branch we take, the result is always a consistent shape. Read"
794794 "union-types"
@@ -801,33 +801,33 @@ toExprReport source localizer exprRegion category tipe expected =
801801 case countArgs tipe of
802802 0 ->
803803 Report.toCodeSnippet source region (Just exprRegion)
804− ( H.reflow $
804+ ( D.reflow $
805805 case maybeFuncName of
806806 NoName -> "This is not a function:"
807807 FuncName name -> "The `" <> N.toString name <> "` value is not a function:"
808808 CtorName name -> "The `" <> N.toString name <> "` value is not a function:"
809809 OpName op -> "The (" <> N.toString op <> ") operator is not a function:"
810810 ,
811− H.stack $
811+ D.stack $
812812 [ "It has type:"
813− , H.indent 4 $ H.dullyellow $ T.toDoc localizer RT.None tipe
814− , H.reflow $ "So it cannot accept arguments, but it got " <> show numArgs <> " anyway."
813+ , D.indent 4 $ D.dullyellow $ T.toDoc localizer RT.None tipe
814+ , D.reflow $ "So it cannot accept arguments, but it got " <> show numArgs <> " anyway."
815815 ]
816816 )
817817
818818 n ->
819819 Report.toCodeSnippet source region (Just exprRegion)
820− ( H.reflow $
820+ ( D.reflow $
821821 case maybeFuncName of
822822 NoName -> "This function was given too many arguments:"
823823 FuncName name -> "The `" <> N.toString name <> "` function was given too many arguments:"
824824 CtorName name -> "The `" <> N.toString name <> "` constructor was given too many arguments:"
825825 OpName op -> "The (" <> N.toString op <> ") operator was given too many arguments:"
826826 ,
827− H.stack $
827+ D.stack $
828828 [ "It has type:"
829− , H.indent 4 $ H.dullyellow $ T.toDoc localizer RT.None tipe
830− , H.reflow $ "So it expects " <> H.args n <> ", but it got " <> show numArgs <> " instead."
829+ , D.indent 4 $ D.dullyellow $ T.toDoc localizer RT.None tipe
830+ , D.reflow $ "So it expects " <> D.args n <> ", but it got " <> show numArgs <> " instead."
831831 ]
832832 )
833833
@@ -842,20 +842,20 @@ toExprReport source localizer exprRegion category tipe expected =
842842 in
843843 Report.toCodeSnippet source region (Just exprRegion)
844844 (
845− H.reflow $
846− "The " <> H.ordinalize (Index.toHuman index) <> " argument to " <> thisFunction <> " is not what I expect:"
845+ D.reflow $
846+ "The " <> D.ordinalize (Index.toHuman index) <> " argument to " <> thisFunction <> " is not what I expect:"
847847 ,
848848 typeComparison localizer tipe expectedType
849849 (
850850 toDescription category "This argument is"
851851 ,
852− "But " <> thisFunction <> " needs the " <> H.ordinalize (Index.toHuman index)
852+ "But " <> thisFunction <> " needs the " <> D.ordinalize (Index.toHuman index)
853853 <> " argument to be:"
854854 ,
855855 if Index.toHuman index == 1 then
856856 []
857857 else
858− [ H.toSimpleHint $
858+ [ D.toSimpleHint $
859859 "I always figure out the argument types from left to right. If an argument\
860860 \ is acceptable, I assume it is “correct” and move on. So the problem may\
861861 \ actually be in one of the previous arguments!"
@@ -868,19 +868,19 @@ toExprReport source localizer exprRegion category tipe expected =
868868 0 ->
869869 Report.toCodeSnippet source region (Just exprRegion)
870870 (
871− H.reflow $
871+ D.reflow $
872872 case maybeName of
873873 NoName ->
874− "You are giving " <> H.args numGivenArgs <> " to something that is not a function!"
874+ "You are giving " <> D.args numGivenArgs <> " to something that is not a function!"
875875
876876 FuncName name ->
877− "`" <> N.toString name <> "` is not a function, but you are giving it " <> H.args numGivenArgs <> "!"
877+ "`" <> N.toString name <> "` is not a function, but you are giving it " <> D.args numGivenArgs <> "!"
878878
879879 CtorName name ->
880− "`" <> N.toString name <> "` is not a function, but you are giving it " <> H.args numGivenArgs <> "!"
880+ "`" <> N.toString name <> "` is not a function, but you are giving it " <> D.args numGivenArgs <> "!"
881881
882882 OpName op ->
883− "(" <> N.toString op <> ") is not a function, but you are giving it " <> H.args numGivenArgs <> "!"
883+ "(" <> N.toString op <> ") is not a function, but you are giving it " <> D.args numGivenArgs <> "!"
884884 ,
885885 typeComparison localizer tipe expectedType
886886 (
@@ -897,7 +897,7 @@ toExprReport source localizer exprRegion category tipe expected =
897897 OpName op ->
898898 "(" <> N.toString op <> ") is a value of type:"
899899 ,
900− "But you are giving it " <> H.args numGivenArgs <> " as if its type was:"
900+ "But you are giving it " <> D.args numGivenArgs <> " as if its type was:"
901901 ,
902902 [ "Maybe you forgot some parentheses? Or a comma?"
903903 ]
@@ -922,17 +922,17 @@ toExprReport source localizer exprRegion category tipe expected =
922922 in
923923 Report.toCodeSnippet source region (Just exprRegion)
924924 (
925− H.reflow $
925+ D.reflow $
926926 thisFunction <> " is getting too many arguments:"
927927 ,
928928 typeComparison localizer tipe expectedType
929929 (
930− thisFunction <> " is expecting to get " <> H.args numExpectedArgs <> " like this:"
930+ thisFunction <> " is expecting to get " <> D.args numExpectedArgs <> " like this:"
931931 ,
932− "But you are giving it " <> H.args numGivenArgs <> " as if its type was:"
932+ "But you are giving it " <> D.args numGivenArgs <> " as if its type was:"
933933 ,
934934 [ "Maybe you forgot some parentheses? Or a comma?"
935− , H.toSimpleNote $
935+ , D.toSimpleNote $
936936 "I am not good at figuring out which arguments are extra myself. The\
937937 \ problem may even be that the FUNCTION is defined funny, and the arguments are\
938938 \ actually fine. Anyway, I hope I gave enough info to help you figure it out!"
@@ -945,15 +945,15 @@ toExprReport source localizer exprRegion category tipe expected =
945945 case tipe of
946946 T.Record _ _ ->
947947 (
948− H.reflow $
948+ D.reflow $
949949 "This record does not have a `" <> N.toString field <> "` field:"
950950 ,
951951 loneType localizer tipe expectedType
952952 (
953− H.reflow $ "It is a record with this type:"
953+ D.reflow $ "It is a record with this type:"
954954 ,
955− [ H.fillSep
956− ["Is","the",H.dullyellow ("." <> H.nameToDoc field)
955+ [ D.fillSep
956+ ["Is","the",D.dullyellow ("." <> D.fromName field)
957957 ,"field","access","is","misspelled?"
958958 ]
959959 ]
@@ -962,14 +962,14 @@ toExprReport source localizer exprRegion category tipe expected =
962962
963963 _ ->
964964 (
965− H.reflow $
965+ D.reflow $
966966 "This is not a record, so it has no fields to access!"
967967 ,
968968 loneType localizer tipe expectedType
969− ( H.reflow $ toDescription category "It is"
970− , [ H.fillSep
969+ ( D.reflow $ toDescription category "It is"
970+ , [ D.fillSep
971971 ["But","I","need","a","record","with","a"
972− ,H.dullyellow (H.nameToDoc field),"field!"
972+ ,D.dullyellow (D.fromName field),"field!"
973973 ]
974974 ]
975975 )
@@ -980,7 +980,7 @@ toExprReport source localizer exprRegion category tipe expected =
980980 T.Record _ _ ->
981981 Report.toCodeSnippet source region Nothing $
982982 (
983− H.reflow $
983+ D.reflow $
984984 "I think there is a typo in one of these field names:"
985985 ,
986986 typeComparison localizer tipe expectedType
@@ -989,7 +989,7 @@ toExprReport source localizer exprRegion category tipe expected =
989989 ,
990990 "But you are saying it should have these fields:"
991991 ,
992− [ H.reflow "Maybe there is some typo?"
992+ [ D.reflow "Maybe there is some typo?"
993993 ]
994994 )
995995 )
@@ -1000,8 +1000,8 @@ toExprReport source localizer exprRegion category tipe expected =
10001000 "The record update syntax does not work with this value:"
10011001 ,
10021002 loneType localizer tipe expectedType
1003− ( H.reflow $ toDescription category "It is"
1004− , [ H.reflow $ "But I need some kind of record here!"
1003+ ( D.reflow $ toDescription category "It is"
1004+ , [ D.reflow $ "But I need some kind of record here!"
10051005 ]
10061006 )
10071007 )
@@ -1009,7 +1009,7 @@ toExprReport source localizer exprRegion category tipe expected =
10091009 Destructure ->
10101010 Report.toCodeSnippet source region Nothing
10111011 (
1012− H.reflow $
1012+ D.reflow $
10131013 "I cannot destructure "
10141014 ,
10151015 typeComparison localizer tipe expectedType
@@ -1041,7 +1041,7 @@ countArgs tipe =
10411041-- OP LEFT
10421042
10431043
1044−opLeftToDocs :: T.Localizer -> Category -> N.Name -> T.Type -> T.Type -> (H.Doc, H.Doc)
1044+opLeftToDocs :: T.Localizer -> Category -> N.Name -> T.Type -> T.Type -> (D.Doc, D.Doc)
10451045opLeftToDocs localizer category op tipe expected =
10461046 case op of
10471047 "+"
@@ -1070,15 +1070,15 @@ opLeftToDocs localizer category op tipe expected =
10701070 ( "The left side of (<|) needs to be a function so I can pipe arguments to it!"
10711071 ,
10721072 loneType localizer tipe expected
1073− ( H.reflow $ toDescription category "I am seeing"
1074− , [ H.reflow $ "This needs to be some kind of function though!"
1073+ ( D.reflow $ toDescription category "I am seeing"
1074+ , [ D.reflow $ "This needs to be some kind of function though!"
10751075 ]
10761076 )
10771077 )
10781078
10791079 _ ->
10801080 (
1081− H.reflow $
1081+ D.reflow $
10821082 "The left argument of (" <> N.toString op <> ") is causing problems:"
10831083 ,
10841084 typeComparison localizer tipe expected
@@ -1097,8 +1097,8 @@ opLeftToDocs localizer category op tipe expected =
10971097
10981098
10991099data RightDocs
1100− = EmphBoth (H.Doc, H.Doc)
1101− | EmphRight (H.Doc, H.Doc)
1100+ = EmphBoth (D.Doc, D.Doc)
1101+ | EmphRight (D.Doc, D.Doc)
11021102
11031103
11041104opRightToDocs :: T.Localizer -> Category -> N.Name -> T.Type -> T.Type -> RightDocs
@@ -1146,7 +1146,7 @@ opRightToDocs localizer category op tipe expected =
11461146 "<|" ->
11471147 EmphRight
11481148 (
1149− H.reflow $
1149+ D.reflow $
11501150 "I cannot send this through the (<|) pipe:"
11511151 ,
11521152 typeComparison localizer tipe expected
@@ -1182,7 +1182,7 @@ opRightToDocs localizer category op tipe expected =
11821182 "The right side of (|>) needs to be a function so I can pipe arguments to it!"
11831183 ,
11841184 loneType localizer tipe expected
1185− ( H.reflow $ toDescription category $
1185+ ( D.reflow $ toDescription category $
11861186 "But instead of a function, I am seeing "
11871187 , []
11881188 )
@@ -1196,7 +1196,7 @@ badOpRightFallback :: T.Localizer -> Category -> N.Name -> T.Type -> T.Type -> R
11961196badOpRightFallback localizer category op tipe expected =
11971197 EmphRight
11981198 (
1199− H.reflow $
1199+ D.reflow $
12001200 "The right argument of (" <> N.toString op <> ") is causing problems."
12011201 ,
12021202 typeComparison localizer tipe expected
@@ -1205,7 +1205,7 @@ badOpRightFallback localizer category op tipe expected =
12051205 ,
12061206 "But (" <> N.toString op <> ") needs the right argument to be:"
12071207 ,
1208− [ H.toSimpleHint $
1208+ [ D.toSimpleHint $
12091209 "With operators like (" ++ N.toString op ++ ") I always check the left\
12101210 \ side first. If it seems fine, I assume it is correct and check the right\
12111211 \ side. So the problem may be in how the left and right arguments interact!"
@@ -1266,7 +1266,7 @@ badConsRight localizer category tipe expected =
12661266 T.Type home2 name2 [expectedElement] | T.isList home2 name2 ->
12671267 EmphBoth
12681268 (
1269− H.reflow "I am having trouble with this (::) operator:"
1269+ D.reflow "I am having trouble with this (::) operator:"
12701270 ,
12711271 typeComparison localizer expectedElement actualElement
12721272 (
@@ -1276,14 +1276,14 @@ badConsRight localizer category tipe expected =
12761276 ,
12771277 case expectedElement of
12781278 T.Type home name [_] | T.isList home name ->
1279− [ H.toSimpleHint
1279+ [ D.toSimpleHint
12801280 "Are you trying to append two lists? The (++) operator\
12811281 \ appends lists, whereas the (::) operator is only for\
12821282 \ adding ONE element to a list."
12831283 ]
12841284
12851285 _ ->
1286− [ H.reflow
1286+ [ D.reflow
12871287 "Lists need ALL elements to be the same type though."
12881288 ]
12891289 )
@@ -1295,13 +1295,13 @@ badConsRight localizer category tipe expected =
12951295 _ ->
12961296 EmphRight
12971297 (
1298− H.reflow "The (::) operator can only add elements onto lists."
1298+ D.reflow "The (::) operator can only add elements onto lists."
12991299 ,
13001300 loneType localizer tipe expected
13011301 (
1302− H.reflow $ toDescription category "The right side is"
1302+ D.reflow $ toDescription category "The right side is"
13031303 ,
1304− [H.fillSep ["But","(::)","needs","a",H.dullyellow "List","on","the","right."]
1304+ [D.fillSep ["But","(::)","needs","a",D.dullyellow "List","on","the","right."]
13051305 ]
13061306 )
13071307 )
@@ -1312,7 +1312,7 @@ badConsRight localizer category tipe expected =
13121312
13131313
13141314data AppendType
1315− = ANumber H.Doc H.Doc
1315+ = ANumber D.Doc D.Doc
13161316 | AString
13171317 | AList
13181318 | AOther
@@ -1332,18 +1332,18 @@ toAppendType tipe =
13321332 _ -> AOther
13331333
13341334
1335−badAppendLeft :: T.Localizer -> Category -> T.Type -> T.Type -> (H.Doc, H.Doc)
1335+badAppendLeft :: T.Localizer -> Category -> T.Type -> T.Type -> (D.Doc, D.Doc)
13361336badAppendLeft localizer category tipe expected =
13371337 case toAppendType tipe of
13381338 ANumber thing stringFromThing ->
13391339 (
1340− H.fillSep
1340+ D.fillSep
13411341 ["The","(++)","operator","can","append","List","and","String"
1342− ,"values,","but","not",H.dullyellow thing,"values","like","this:"
1342+ ,"values,","but","not",D.dullyellow thing,"values","like","this:"
13431343 ]
13441344 ,
1345− H.fillSep
1346− ["Try","using",H.green stringFromThing,"to","turn","it","into","a","string?"
1345+ D.fillSep
1346+ ["Try","using",D.green stringFromThing,"to","turn","it","into","a","string?"
13471347 ,"Or","put","it","in","[]","to","make","it","a","list?"
13481348 ,"Or","switch","to","the","(::)","operator?"
13491349 ]
@@ -1351,15 +1351,15 @@ badAppendLeft localizer category tipe expected =
13511351
13521352 _ ->
13531353 (
1354− H.reflow $
1354+ D.reflow $
13551355 "The (++) operator cannot append this type of value:"
13561356 ,
13571357 loneType localizer tipe expected
1358− ( H.reflow $ toDescription category "I am seeing"
1358+ ( D.reflow $ toDescription category "I am seeing"
13591359 ,
1360− [ H.fillSep
1360+ [ D.fillSep
13611361 ["But","the","(++)","operator","is","only","for","appending"
1362− ,H.dullyellow "List","and",H.dullyellow "String","values."
1362+ ,D.dullyellow "List","and",D.dullyellow "String","values."
13631363 ,"Maybe","put","this","value","in","[]","to","make","it","a","list?"
13641364 ]
13651365 ]
@@ -1373,13 +1373,13 @@ badAppendRight localizer category tipe expected =
13731373 (AString, ANumber thing stringFromThing) ->
13741374 EmphRight
13751375 (
1376− H.fillSep
1377− ["I","thought","I","was","appending",H.dullyellow "String","values","here,"
1378− ,"not",H.dullyellow thing,"values","like","this:"
1376+ D.fillSep
1377+ ["I","thought","I","was","appending",D.dullyellow "String","values","here,"
1378+ ,"not",D.dullyellow thing,"values","like","this:"
13791379 ]
13801380 ,
1381− H.fillSep
1382− ["Try","using",H.green stringFromThing
1381+ D.fillSep
1382+ ["Try","using",D.green stringFromThing
13831383 ,"to","turn","it","into","a","string?"
13841384 ]
13851385 )
@@ -1387,23 +1387,23 @@ badAppendRight localizer category tipe expected =
13871387 (AList, ANumber thing _) ->
13881388 EmphRight
13891389 (
1390− H.fillSep
1391− ["I","thought","I","was","appending",H.dullyellow "List","values","here,"
1392− ,"not",H.dullyellow thing,"values","like","this:"
1390+ D.fillSep
1391+ ["I","thought","I","was","appending",D.dullyellow "List","values","here,"
1392+ ,"not",D.dullyellow thing,"values","like","this:"
13931393 ]
13941394 ,
1395− H.reflow "Try putting it in [] to make it a list?"
1395+ D.reflow "Try putting it in [] to make it a list?"
13961396 )
13971397
13981398 (AString, AList) ->
13991399 EmphBoth
14001400 (
1401− H.reflow $
1401+ D.reflow $
14021402 "The (++) operator needs the same type of value on both sides:"
14031403 ,
1404− H.fillSep
1405− ["I","see","a",H.dullyellow "String","on","the","left","and","a"
1406− ,H.dullyellow "List","on","the","right.","Which","should","it","be?"
1404+ D.fillSep
1405+ ["I","see","a",D.dullyellow "String","on","the","left","and","a"
1406+ ,D.dullyellow "List","on","the","right.","Which","should","it","be?"
14071407 ,"Does","the","string","need","[]","around","it","to","become","a","list?"
14081408 ]
14091409 )
@@ -1411,12 +1411,12 @@ badAppendRight localizer category tipe expected =
14111411 (AList, AString) ->
14121412 EmphBoth
14131413 (
1414− H.reflow $
1414+ D.reflow $
14151415 "The (++) operator needs the same type of value on both sides:"
14161416 ,
1417− H.fillSep
1418− ["I","see","a",H.dullyellow "List","on","the","left","and","a"
1419− ,H.dullyellow "String","on","the","right.","Which","should","it","be?"
1417+ D.fillSep
1418+ ["I","see","a",D.dullyellow "List","on","the","left","and","a"
1419+ ,D.dullyellow "String","on","the","right.","Which","should","it","be?"
14201420 ,"Does","the","string","need","[]","around","it","to","become","a","list?"
14211421 ]
14221422 )
@@ -1424,7 +1424,7 @@ badAppendRight localizer category tipe expected =
14241424 (_,_) ->
14251425 EmphBoth
14261426 (
1427− H.reflow $
1427+ D.reflow $
14281428 "The (++) operator cannot append these two values:"
14291429 ,
14301430 typeComparison localizer expected tipe
@@ -1450,14 +1450,14 @@ badCast :: N.Name -> ThisThenThat -> RightDocs
14501450badCast op thisThenThat =
14511451 EmphBoth
14521452 (
1453− H.text $
1453+ D.reflow $
14541454 "I need both sides of (" <> N.toString op <> ") to be the exact same type. Both Int or both Float."
14551455 ,
14561456 let
1457− anInt = ["an", H.dullyellow "Int"]
1458− aFloat = ["a", H.dullyellow "Float"]
1459− toFloat = H.green "toFloat"
1460− round = H.green "round"
1457+ anInt = ["an", D.dullyellow "Int"]
1458+ aFloat = ["a", D.dullyellow "Float"]
1459+ toFloat = D.green "toFloat"
1460+ round = D.green "round"
14611461 in
14621462 case thisThenThat of
14631463 FloatInt ->
@@ -1468,85 +1468,85 @@ badCast op thisThenThat =
14681468 )
14691469
14701470
1471−badCastHelp :: [H.Doc] -> [H.Doc] -> H.Doc -> H.Doc -> H.Doc
1471+badCastHelp :: [D.Doc] -> [D.Doc] -> D.Doc -> D.Doc -> D.Doc
14721472badCastHelp anInt aFloat toFloat round =
1473− H.stack
1474− [ H.fillSep $
1473+ D.stack
1474+ [ D.fillSep $
14751475 ["But","I","see"]
14761476 ++ anInt
14771477 ++ ["on","the","left","and"]
14781478 ++ aFloat
14791479 ++ ["on","the","right."]
1480− , H.fillSep
1480+ , D.fillSep
14811481 ["Use",toFloat,"on","the","left","(or",round,"on"
14821482 ,"the","right)","to","make","both","sides","match!"
14831483 ]
1484− , H.link "Note" "Read" "implicit-casts" "to learn why Elm does not implicitly convert Ints to Floats."
1484+ , D.link "Note" "Read" "implicit-casts" "to learn why Elm does not implicitly convert Ints to Floats."
14851485 ]
14861486
14871487
1488−badStringAdd :: (H.Doc, H.Doc)
1488+badStringAdd :: (D.Doc, D.Doc)
14891489badStringAdd =
14901490 (
1491− H.fillSep ["I","cannot","do","addition","with",H.dullyellow "String","values","like","this","one:"]
1491+ D.fillSep ["I","cannot","do","addition","with",D.dullyellow "String","values","like","this","one:"]
14921492 ,
1493− H.stack
1494− [ H.fillSep
1495− ["The","(+)","operator","only","works","with",H.dullyellow "Int","and",H.dullyellow "Float","values."
1493+ D.stack
1494+ [ D.fillSep
1495+ ["The","(+)","operator","only","works","with",D.dullyellow "Int","and",D.dullyellow "Float","values."
14961496 ]
1497− , H.toFancyHint
1498− ["Switch","to","the",H.green "(++)","operator","to","append","strings!"
1497+ , D.toFancyHint
1498+ ["Switch","to","the",D.green "(++)","operator","to","append","strings!"
14991499 ]
15001500 ]
15011501 )
15021502
15031503
1504−badListAdd :: T.Localizer -> Category -> String -> T.Type -> T.Type -> (H.Doc, H.Doc)
1504+badListAdd :: T.Localizer -> Category -> String -> T.Type -> T.Type -> (D.Doc, D.Doc)
15051505badListAdd localizer category direction tipe expected =
15061506 (
15071507 "I cannot do addition with lists:"
15081508 ,
15091509 loneType localizer tipe expected
15101510 (
1511− H.reflow $ toDescription category $
1511+ D.reflow $ toDescription category $
15121512 "The " <> direction <> " side of (+) is"
15131513 ,
1514− [ H.fillSep
1515− ["But","(+)","only","works","with",H.dullyellow "Int","and",H.dullyellow "Float","values."
1514+ [ D.fillSep
1515+ ["But","(+)","only","works","with",D.dullyellow "Int","and",D.dullyellow "Float","values."
15161516 ]
1517− , H.toFancyHint
1518− ["Switch","to","the",H.green "(++)","operator","to","append","lists!"
1517+ , D.toFancyHint
1518+ ["Switch","to","the",D.green "(++)","operator","to","append","lists!"
15191519 ]
15201520 ]
15211521 )
15221522 )
15231523
15241524
1525−badListMul :: T.Localizer -> Category -> String -> T.Type -> T.Type -> (H.Doc, H.Doc)
1525+badListMul :: T.Localizer -> Category -> String -> T.Type -> T.Type -> (D.Doc, D.Doc)
15261526badListMul localizer category direction tipe expected =
15271527 badMath localizer category "Multiplication" direction "*" tipe expected
15281528 [
1529− H.toFancyHint
1529+ D.toFancyHint
15301530 [ "Maybe", "you", "want"
1531− , H.green "List.repeat"
1531+ , D.green "List.repeat"
15321532 , "to", "build","a","list","of","repeated","values?"
15331533 ]
15341534 ]
15351535
15361536
1537−badMath :: T.Localizer -> Category -> String -> String -> String -> T.Type -> T.Type -> [H.Doc] -> (H.Doc, H.Doc)
1537+badMath :: T.Localizer -> Category -> String -> String -> String -> T.Type -> T.Type -> [D.Doc] -> (D.Doc, D.Doc)
15381538badMath localizer category operation direction op tipe expected otherHints =
15391539 (
1540− H.reflow $
1540+ D.reflow $
15411541 operation ++ " does not work with this value:"
15421542 ,
15431543 loneType localizer tipe expected
1544− ( H.reflow $ toDescription category $
1544+ ( D.reflow $ toDescription category $
15451545 "The " <> direction <> " side of (" <> op <> ") is"
15461546 ,
1547− [ H.fillSep
1548− ["But","(" <> H.text op <> ")","only","works","with"
1549− ,H.dullyellow "Int","and",H.dullyellow "Float","values."
1547+ [ D.fillSep
1548+ ["But","(" <> D.fromString op <> ")","only","works","with"
1549+ ,D.dullyellow "Int","and",D.dullyellow "Float","values."
15501550 ]
15511551 ]
15521552 ++ otherHints
@@ -1554,33 +1554,33 @@ badMath localizer category operation direction op tipe expected otherHints =
15541554 )
15551555
15561556
1557−badFDiv :: T.Localizer -> H.Doc -> T.Type -> T.Type -> (H.Doc, H.Doc)
1557+badFDiv :: T.Localizer -> D.Doc -> T.Type -> T.Type -> (D.Doc, D.Doc)
15581558badFDiv localizer direction tipe expected =
15591559 (
1560− H.reflow $
1560+ D.reflow $
15611561 "The (/) operator is specifically for floating-point division:"
15621562 ,
15631563 if isInt tipe then
1564− H.stack
1565− [ H.fillSep
1564+ D.stack
1565+ [ D.fillSep
15661566 ["The",direction,"side","of","(/)","must","be","a"
1567− ,H.dullyellow "Float" <> ","
1568− ,"but","I","am","seeing","an",H.dullyellow "Int" <> "."
1567+ ,D.dullyellow "Float" <> ","
1568+ ,"but","I","am","seeing","an",D.dullyellow "Int" <> "."
15691569 ,"I","recommend:"
15701570 ]
1571− , H.vcat
1572− [ H.green "toFloat" <> " for explicit conversions " <> H.black "(toFloat 5 / 2) == 2.5"
1573− , H.green "(//) " <> " for integer division " <> H.black "(5 // 2) == 2"
1571+ , D.vcat
1572+ [ D.green "toFloat" <> " for explicit conversions " <> D.black "(toFloat 5 / 2) == 2.5"
1573+ , D.green "(//) " <> " for integer division " <> D.black "(5 // 2) == 2"
15741574 ]
1575− , H.link "Note" "Read" "implicit-casts" "to learn why Elm does not implicitly convert Ints to Floats."
1575+ , D.link "Note" "Read" "implicit-casts" "to learn why Elm does not implicitly convert Ints to Floats."
15761576 ]
15771577
15781578 else
15791579 loneType localizer tipe expected
15801580 (
1581− H.fillSep
1581+ D.fillSep
15821582 ["The",direction,"side","of","(/)","must","be","a"
1583− ,H.dullyellow "Float" <> ","
1583+ ,D.dullyellow "Float" <> ","
15841584 ,"but","instead","I","am","seeing:"
15851585 ]
15861586 , []
@@ -1588,35 +1588,35 @@ badFDiv localizer direction tipe expected =
15881588 )
15891589
15901590
1591−badIDiv :: T.Localizer -> H.Doc -> T.Type -> T.Type -> (H.Doc, H.Doc)
1591+badIDiv :: T.Localizer -> D.Doc -> T.Type -> T.Type -> (D.Doc, D.Doc)
15921592badIDiv localizer direction tipe expected =
15931593 (
1594− H.reflow $
1594+ D.reflow $
15951595 "The (//) operator is specifically for integer division:"
15961596 ,
15971597 if isFloat tipe then
1598− H.stack
1599− [ H.fillSep
1598+ D.stack
1599+ [ D.fillSep
16001600 ["The",direction,"side","of","(//)","must","be","an"
1601− ,H.dullyellow "Int" <> ","
1602− ,"but","I","am","seeing","a",H.dullyellow "Float" <> "."
1601+ ,D.dullyellow "Int" <> ","
1602+ ,"but","I","am","seeing","a",D.dullyellow "Float" <> "."
16031603 ,"I","recommend","doing","the","conversion","explicitly"
16041604 ,"with","one","of","these","functions:"
16051605 ]
1606− , H.vcat
1607− [ H.green "round" <> " 3.5 == 4"
1608− , H.green "floor" <> " 3.5 == 3"
1609− , H.green "ceiling" <> " 3.5 == 4"
1610− , H.green "truncate" <> " 3.5 == 3"
1606+ , D.vcat
1607+ [ D.green "round" <> " 3.5 == 4"
1608+ , D.green "floor" <> " 3.5 == 3"
1609+ , D.green "ceiling" <> " 3.5 == 4"
1610+ , D.green "truncate" <> " 3.5 == 3"
16111611 ]
1612− , H.link "Note" "Read" "implicit-casts" "to learn why Elm does not implicitly convert Ints to Floats."
1612+ , D.link "Note" "Read" "implicit-casts" "to learn why Elm does not implicitly convert Ints to Floats."
16131613 ]
16141614 else
16151615 loneType localizer tipe expected
16161616 (
1617− H.fillSep
1617+ D.fillSep
16181618 ["The",direction,"side","of","(//)","must","be","an"
1619− ,H.dullyellow "Int" <> ","
1619+ ,D.dullyellow "Int" <> ","
16201620 ,"but","instead","I","am","seeing:"
16211621 ]
16221622 , []
@@ -1628,17 +1628,17 @@ badIDiv localizer direction tipe expected =
16281628-- BAD BOOLS
16291629
16301630
1631−badBool :: T.Localizer -> H.Doc -> H.Doc -> T.Type -> T.Type -> (H.Doc, H.Doc)
1631+badBool :: T.Localizer -> D.Doc -> D.Doc -> T.Type -> T.Type -> (D.Doc, D.Doc)
16321632badBool localizer op direction tipe expected =
16331633 (
1634− H.reflow $
1634+ D.reflow $
16351635 "I am struggling with this boolean operation:"
16361636 ,
16371637 loneType localizer tipe expected
16381638 (
1639− H.fillSep
1639+ D.fillSep
16401640 ["Both","sides","of","(" <> op <> ")","must","be"
1641− ,H.dullyellow "Bool","values,","but","the",direction,"side","is:"
1641+ ,D.dullyellow "Bool","values,","but","the",direction,"side","is:"
16421642 ]
16431643 ,
16441644 []
@@ -1650,24 +1650,24 @@ badBool localizer op direction tipe expected =
16501650-- BAD COMPARISON
16511651
16521652
1653−badCompLeft :: T.Localizer -> Category -> String -> String -> T.Type -> T.Type -> (H.Doc, H.Doc)
1653+badCompLeft :: T.Localizer -> Category -> String -> String -> T.Type -> T.Type -> (D.Doc, D.Doc)
16541654badCompLeft localizer category op direction tipe expected =
16551655 (
1656− H.reflow $
1656+ D.reflow $
16571657 "I cannot do a comparison with this value:"
16581658 ,
16591659 loneType localizer tipe expected
16601660 (
1661− H.reflow $ toDescription category $
1661+ D.reflow $ toDescription category $
16621662 "The " <> direction <> " side of (" <> op <> ") is"
16631663 ,
1664− [ H.fillSep
1665− ["But","(" <> H.text op <> ")","only","works","on"
1666− ,H.dullyellow "Int" <> ","
1667− ,H.dullyellow "Float" <> ","
1668− ,H.dullyellow "Char" <> ","
1664+ [ D.fillSep
1665+ ["But","(" <> D.fromString op <> ")","only","works","on"
1666+ ,D.dullyellow "Int" <> ","
1667+ ,D.dullyellow "Float" <> ","
1668+ ,D.dullyellow "Char" <> ","
16691669 ,"and"
1670− ,H.dullyellow "String"
1670+ ,D.dullyellow "String"
16711671 ,"values.","It","can","work","on","lists","and","tuples"
16721672 ,"of","comparable","values","as","well,","but","it","is"
16731673 ,"usually","better","to","find","a","different","path."
@@ -1681,7 +1681,7 @@ badCompRight :: T.Localizer -> String -> T.Type -> T.Type -> RightDocs
16811681badCompRight localizer op tipe expected =
16821682 EmphBoth
16831683 (
1684− H.reflow $
1684+ D.reflow $
16851685 "I need both sides of (" <> op <> ") to be the same type:"
16861686 ,
16871687 typeComparison localizer expected tipe
@@ -1690,7 +1690,7 @@ badCompRight localizer op tipe expected =
16901690 ,
16911691 "But the right side is:"
16921692 ,
1693− [ H.reflow $
1693+ [ D.reflow $
16941694 "I cannot compare different types though! Which side of (" <> op <> ") is the problem?"
16951695 ]
16961696 )
@@ -1705,7 +1705,7 @@ badEquality :: T.Localizer -> String -> T.Type -> T.Type -> RightDocs
17051705badEquality localizer op tipe expected =
17061706 EmphBoth
17071707 (
1708− H.reflow $
1708+ D.reflow $
17091709 "I need both sides of (" <> op <> ") to be the same type:"
17101710 ,
17111711 typeComparison localizer expected tipe
@@ -1715,12 +1715,12 @@ badEquality localizer op tipe expected =
17151715 "But the right side is:"
17161716 ,
17171717 if isFloat tipe || isFloat expected then
1718− [ H.toSimpleNote $
1718+ [ D.toSimpleNote $
17191719 "Equality on floats is not 100% reliable due to the design of IEEE 754. I\
17201720 \ recommend a check like (abs (x - y) < 0.0001) instead."
17211721 ]
17221722 else
1723− [ H.reflow $
1723+ [ D.reflow $
17241724 "Different types can never be equal though! Which side is messed up?"
17251725 ]
17261726 )
@@ -1736,15 +1736,15 @@ toInfiniteReport source localizer region name overallType =
17361736 Report.Report "INFINITE TYPE" region [] $
17371737 Report.toCodeSnippet source region Nothing
17381738 (
1739− H.reflow $
1739+ D.reflow $
17401740 "I am inferring a weird self-referential type for " <> N.toString name <> ":"
17411741 ,
1742− H.stack
1743− [ H.reflow $
1742+ D.stack
1743+ [ D.reflow $
17441744 "Here is my best effort at writing down the type. You will see ∞ for\
17451745 \ parts of the type that repeat something already printed out infinitely."
1746− , H.indent 4 (H.dullyellow (T.toDoc localizer RT.None overallType))
1747− , H.reflowLink
1746+ , D.indent 4 (D.dullyellow (T.toDoc localizer RT.None overallType))
1747+ , D.reflowLink
17481748 "Staring at the type is usually not so helpful, so I recommend reading the hints at"
17491749 "infinite-type"
17501750 "to get unstuck."