@@ -25,7 +25,6 @@ import qualified Elm.ModuleName as ModuleName
2525import qualified Reporting.Annotation as A
2626import qualified Reporting.Doc as D
2727import Reporting.Doc (Doc, (<+>), (<>))
28−import qualified Reporting.Region as R
2928import qualified Reporting.Render.Code as Code
3029import qualified Reporting.Render.Type as RT
3130import qualified Reporting.Report as Report
@@ -37,44 +36,44 @@ import qualified Reporting.Suggest as Suggest
3736
3837
3938data Error
40− = AnnotationTooShort R.Region Name.Name Index.ZeroBased Int
41− | AmbiguousVar R.Region (Maybe Name.Name) Name.Name [ModuleName.Canonical]
42− | AmbiguousType R.Region (Maybe Name.Name) Name.Name [ModuleName.Canonical]
43− | AmbiguousCtor R.Region (Maybe Name.Name) Name.Name [ModuleName.Canonical]
44− | AmbiguousBinop R.Region Name.Name [ModuleName.Canonical]
45− | BadArity R.Region BadArityContext Name.Name Int Int
46− | Binop R.Region Name.Name Name.Name
47− | DuplicateDecl Name.Name R.Region R.Region
48− | DuplicateType Name.Name R.Region R.Region
49− | DuplicateCtor Name.Name R.Region R.Region
50− | DuplicateBinop Name.Name R.Region R.Region
51− | DuplicateField Name.Name R.Region R.Region
52− | DuplicateAliasArg Name.Name Name.Name R.Region R.Region
53− | DuplicateUnionArg Name.Name Name.Name R.Region R.Region
54− | DuplicatePattern DuplicatePatternContext Name.Name R.Region R.Region
55− | EffectNotFound R.Region Name.Name
56− | EffectFunctionNotFound R.Region Name.Name
57− | ExportDuplicate Name.Name R.Region R.Region
58− | ExportNotFound R.Region VarKind Name.Name [Name.Name]
59− | ExportOpenAlias R.Region Name.Name
60− | ImportCtorByName R.Region Name.Name Name.Name
61− | ImportNotFound R.Region Name.Name [ModuleName.Canonical]
62− | ImportOpenAlias R.Region Name.Name
63− | ImportExposingNotFound R.Region ModuleName.Canonical Name.Name [Name.Name]
64− | NotFoundVar R.Region (Maybe Name.Name) Name.Name PossibleNames
65− | NotFoundType R.Region (Maybe Name.Name) Name.Name PossibleNames
66− | NotFoundCtor R.Region (Maybe Name.Name) Name.Name PossibleNames
67− | NotFoundBinop R.Region Name.Name (Set.Set Name.Name)
68− | PatternHasRecordCtor R.Region Name.Name
69− | PortPayloadInvalid R.Region Name.Name Can.Type InvalidPayload
70− | PortTypeInvalid R.Region Name.Name PortProblem
71− | RecursiveAlias R.Region Name.Name [Name.Name] Src.Type [Name.Name]
39+ = AnnotationTooShort A.Region Name.Name Index.ZeroBased Int
40+ | AmbiguousVar A.Region (Maybe Name.Name) Name.Name [ModuleName.Canonical]
41+ | AmbiguousType A.Region (Maybe Name.Name) Name.Name [ModuleName.Canonical]
42+ | AmbiguousVariant A.Region (Maybe Name.Name) Name.Name [ModuleName.Canonical]
43+ | AmbiguousBinop A.Region Name.Name [ModuleName.Canonical]
44+ | BadArity A.Region BadArityContext Name.Name Int Int
45+ | Binop A.Region Name.Name Name.Name
46+ | DuplicateDecl Name.Name A.Region A.Region
47+ | DuplicateType Name.Name A.Region A.Region
48+ | DuplicateCtor Name.Name A.Region A.Region
49+ | DuplicateBinop Name.Name A.Region A.Region
50+ | DuplicateField Name.Name A.Region A.Region
51+ | DuplicateAliasArg Name.Name Name.Name A.Region A.Region
52+ | DuplicateUnionArg Name.Name Name.Name A.Region A.Region
53+ | DuplicatePattern DuplicatePatternContext Name.Name A.Region A.Region
54+ | EffectNotFound A.Region Name.Name
55+ | EffectFunctionNotFound A.Region Name.Name
56+ | ExportDuplicate Name.Name A.Region A.Region
57+ | ExportNotFound A.Region VarKind Name.Name [Name.Name]
58+ | ExportOpenAlias A.Region Name.Name
59+ | ImportCtorByName A.Region Name.Name Name.Name
60+ | ImportNotFound A.Region Name.Name [ModuleName.Canonical]
61+ | ImportOpenAlias A.Region Name.Name
62+ | ImportExposingNotFound A.Region ModuleName.Canonical Name.Name [Name.Name]
63+ | NotFoundVar A.Region (Maybe Name.Name) Name.Name PossibleNames
64+ | NotFoundType A.Region (Maybe Name.Name) Name.Name PossibleNames
65+ | NotFoundVariant A.Region (Maybe Name.Name) Name.Name PossibleNames
66+ | NotFoundBinop A.Region Name.Name (Set.Set Name.Name)
67+ | PatternHasRecordCtor A.Region Name.Name
68+ | PortPayloadInvalid A.Region Name.Name Can.Type InvalidPayload
69+ | PortTypeInvalid A.Region Name.Name PortProblem
70+ | RecursiveAlias A.Region Name.Name [Name.Name] Src.Type [Name.Name]
7271 | RecursiveDecl [Can.Def]
7372 | RecursiveLet (A.Located Name.Name) [Name.Name]
74− | Shadowing Name.Name R.Region R.Region
75− | TupleLargerThanThree R.Region
76− | TypeVarsUnboundInUnion R.Region Name.Name [Name.Name] (Name.Name, R.Region) [(Name.Name, R.Region)]
77− | TypeVarsMessedUpInAlias R.Region Name.Name [Name.Name] [(Name.Name, R.Region)] [(Name.Name, R.Region)]
73+ | Shadowing Name.Name A.Region A.Region
74+ | TupleLargerThanThree A.Region
75+ | TypeVarsUnboundInUnion A.Region Name.Name [Name.Name] (Name.Name, A.Region) [(Name.Name, A.Region)]
76+ | TypeVarsMessedUpInAlias A.Region Name.Name [Name.Name] [(Name.Name, A.Region)] [(Name.Name, A.Region)]
7877
7978
8079data BadArityContext
@@ -155,7 +154,7 @@ toReport source err =
155154 Report.toCodeSnippet source region Nothing
156155 (
157156 D.reflow $
158− "The type annotation for `" <> Name.toString name <> "` says it can accept "
157+ "The type annotation for `" <> Name.toChars name <> "` says it can accept "
159158 <> D.args numTypeArgs <> ", but the definition says it has "
160159 <> D.args numDefArgs <> ":"
161160 ,
@@ -171,8 +170,8 @@ toReport source err =
171170 AmbiguousType region maybePrefix name possibleHomes ->
172171 ambiguousName source region maybePrefix name possibleHomes "type"
173172
174− AmbiguousCtor region maybePrefix name possibleHomes ->
175− ambiguousName source region maybePrefix name possibleHomes "constructor"
173+ AmbiguousVariant region maybePrefix name possibleHomes ->
174+ ambiguousName source region maybePrefix name possibleHomes "variant"
176175
177176 AmbiguousBinop region name possibleHomes ->
178177 ambiguousName source region Nothing name possibleHomes "operator"
@@ -182,14 +181,14 @@ toReport source err =
182181 thing =
183182 case badArityContext of
184183 TypeArity -> "type"
185− PatternArity -> "constructor"
184+ PatternArity -> "variant"
186185 in
187186 if actual < expected then
188187 Report.Report "TOO FEW ARGS" region [] $
189188 Report.toCodeSnippet source region Nothing
190189 (
191190 D.reflow $
192− "The `" <> Name.toString name <> "` " <> thing <> " needs "
191+ "The `" <> Name.toChars name <> "` " <> thing <> " needs "
193192 <> D.args expected <> ", but I see " <> show actual <> " instead:"
194193 ,
195194 D.reflow $
@@ -201,7 +200,7 @@ toReport source err =
201200 Report.toCodeSnippet source region Nothing
202201 (
203202 D.reflow $
204− "The `" <> Name.toString name <> "` " <> thing <> " needs "
203+ "The `" <> Name.toChars name <> "` " <> thing <> " needs "
205204 <> D.args expected <> ", but I see " <> show actual <> " instead:"
206205 ,
207206 if actual - expected == 1 then
@@ -215,7 +214,7 @@ toReport source err =
215214 Report.toCodeSnippet source region Nothing
216215 (
217216 D.reflow $
218− "You cannot mix (" <> Name.toString op1 <> ") and (" <> Name.toString op2 <> ") without parentheses."
217+ "You cannot mix (" <> Name.toChars op1 <> ") and (" <> Name.toChars op2 <> ") without parentheses."
219218 ,
220219 D.reflow
221220 "I do not know how to group these expressions. Add parentheses for me!"
@@ -223,59 +222,59 @@ toReport source err =
223222
224223 DuplicateDecl name r1 r2 ->
225224 nameClash source r1 r2 $
226− "This file has multiple `" <> Name.toString name <> "` declarations."
225+ "This file has multiple `" <> Name.toChars name <> "` declarations."
227226
228227 DuplicateType name r1 r2 ->
229228 nameClash source r1 r2 $
230− "This file defines multiple `" <> Name.toString name <> "` types."
229+ "This file defines multiple `" <> Name.toChars name <> "` types."
231230
232231 DuplicateCtor name r1 r2 ->
233232 nameClash source r1 r2 $
234− "This file defines multiple `" <> Name.toString name <> "` type constructors."
233+ "This file defines multiple `" <> Name.toChars name <> "` type constructors."
235234
236235 DuplicateBinop name r1 r2 ->
237236 nameClash source r1 r2 $
238− "This file defines multiple (" <> Name.toString name <> ") operators."
237+ "This file defines multiple (" <> Name.toChars name <> ") operators."
239238
240239 DuplicateField name r1 r2 ->
241240 nameClash source r1 r2 $
242− "This record has multiple `" <> Name.toString name <> "` fields."
241+ "This record has multiple `" <> Name.toChars name <> "` fields."
243242
244243 DuplicateAliasArg typeName name r1 r2 ->
245244 nameClash source r1 r2 $
246− "The `" <> Name.toString typeName <> "` type alias has multilpe `" <> Name.toString name <> "` type variables."
245+ "The `" <> Name.toChars typeName <> "` type alias has multilpe `" <> Name.toChars name <> "` type variables."
247246
248247 DuplicateUnionArg typeName name r1 r2 ->
249248 nameClash source r1 r2 $
250− "The `" <> Name.toString typeName <> "` type has multilpe `" <> Name.toString name <> "` type variables."
249+ "The `" <> Name.toChars typeName <> "` type has multilpe `" <> Name.toChars name <> "` type variables."
251250
252251 DuplicatePattern context name r1 r2 ->
253252 nameClash source r1 r2 $
254253 case context of
255254 DPLambdaArgs ->
256− "This anonymous function has multiple `" <> Name.toString name <> "` arguments."
255+ "This anonymous function has multiple `" <> Name.toChars name <> "` arguments."
257256
258257 DPFuncArgs funcName ->
259− "The `" <> Name.toString funcName <> "` function has multiple `" <> Name.toString name <> "` arguments."
258+ "The `" <> Name.toChars funcName <> "` function has multiple `" <> Name.toChars name <> "` arguments."
260259
261260 DPCaseBranch ->
262− "This `case` pattern has multiple `" <> Name.toString name <> "` variables."
261+ "This `case` pattern has multiple `" <> Name.toChars name <> "` variables."
263262
264263 DPLetBinding ->
265− "This `let` expression defines `" <> Name.toString name <> "` more than once!"
264+ "This `let` expression defines `" <> Name.toChars name <> "` more than once!"
266265
267266 DPDestruct ->
268− "This pattern contains multiple `" <> Name.toString name <> "` variables."
267+ "This pattern contains multiple `" <> Name.toChars name <> "` variables."
269268
270269 EffectNotFound region name ->
271270 Report.Report "EFFECT PROBLEM" region [] $
272271 Report.toCodeSnippet source region Nothing
273272 (
274273 D.reflow $
275− "You have declared that `" ++ Name.toString name ++ "` is an effect type:"
274+ "You have declared that `" ++ Name.toChars name ++ "` is an effect type:"
276275 ,
277276 D.reflow $
278− "But I cannot find a union type named `" ++ Name.toString name ++ "` in this file!"
277+ "But I cannot find a union type named `" ++ Name.toChars name ++ "` in this file!"
279278 )
280279
281280 EffectFunctionNotFound region name ->
@@ -283,17 +282,17 @@ toReport source err =
283282 Report.toCodeSnippet source region Nothing
284283 (
285284 D.reflow $
286− "This kind of effect module must define a `" ++ Name.toString name ++ "` function."
285+ "This kind of effect module must define a `" ++ Name.toChars name ++ "` function."
287286 ,
288287 D.reflow $
289− "But I cannot find `" ++ Name.toString name ++ "` in this file!"
288+ "But I cannot find `" ++ Name.toChars name ++ "` in this file!"
290289 )
291290
292291
293292 ExportDuplicate name r1 r2 ->
294293 let
295294 messageThatEndsWithPunctuation =
296− "You are trying to expose `" <> Name.toString name <> "` multiple times!"
295+ "You are trying to expose `" <> Name.toChars name <> "` multiple times!"
297296 in
298297 Report.Report "REDUNDANT EXPORT" r2 [] $
299298 Report.toCodePair source r1 r2
@@ -313,8 +312,8 @@ toReport source err =
313312 ExportNotFound region kind rawName possibleNames ->
314313 let
315314 suggestions =
316− map Name.toString $ take 4 $
317− Suggest.sort (Name.toString rawName) Name.toString possibleNames
315+ map Name.toChars $ take 4 $
316+ Suggest.sort (Name.toChars rawName) Name.toChars possibleNames
318317 in
319318 Report.Report "UNKNOWN EXPORT" region suggestions $
320319 let (a, thing, name) = toKindInfo kind rawName in
@@ -323,7 +322,7 @@ toReport source err =
323322 ["You","are","trying","to","expose",a,thing,"named"
324323 ,name,"but","I","cannot","find","its","definition."
325324 ]
326− , case map D.fromString suggestions of
325+ , case map D.fromChars suggestions of
327326 [] ->
328327 D.reflow $
329328 "I do not see any super similar names in this file. Is the definition missing?"
@@ -344,7 +343,7 @@ toReport source err =
344343 (
345344 D.reflow $
346345 "The (..) syntax is for exposing union type constructors. It cannot be used with a type alias like `"
347− ++ Name.toString name ++ "` though."
346+ ++ Name.toChars name ++ "` though."
348347 ,
349348 D.reflow $
350349 "Remove the (..) and you should be fine!"
@@ -355,7 +354,7 @@ toReport source err =
355354 Report.toCodeSnippet source region Nothing
356355 (
357356 D.reflow $
358− "You are trying to import the `" <> Name.toString ctor
357+ "You are trying to import the `" <> Name.toChars ctor
359358 <> "` type constructor by name:"
360359 ,
361360 D.fillSep
@@ -375,7 +374,7 @@ toReport source err =
375374 Report.toCodeSnippet source region Nothing
376375 (
377376 D.reflow $
378− "I could not find a `" <> Name.toString name <> "` module to import!"
377+ "I could not find a `" <> Name.toChars name <> "` module to import!"
379378 ,
380379 mempty
381380 )
@@ -385,7 +384,7 @@ toReport source err =
385384 Report.toCodeSnippet source region Nothing
386385 (
387386 D.reflow $
388− "The `" <> Name.toString name <> "` type alias cannot be followed by (..) like this:"
387+ "The `" <> Name.toChars name <> "` type alias cannot be followed by (..) like this:"
389388 ,
390389 D.stack
391390 [ "Remove the (..) and it should work."
@@ -399,18 +398,18 @@ toReport source err =
399398 ImportExposingNotFound region (ModuleName.Canonical _ home) value possibleNames ->
400399 let
401400 suggestions =
402− map Name.toString $ take 4 $
403− Suggest.sort (Name.toString home) Name.toString possibleNames
401+ map Name.toChars $ take 4 $
402+ Suggest.sort (Name.toChars home) Name.toChars possibleNames
404403 in
405404 Report.Report "BAD IMPORT" region suggestions $
406405 Report.toCodeSnippet source region Nothing
407406 (
408407 D.reflow $
409− "The `" <> Name.toString home
408+ "The `" <> Name.toChars home
410409 <> "` module does not expose `"
411− <> Name.toString value <> "`:"
410+ <> Name.toChars value <> "`:"
412411 ,
413− case map D.fromString suggestions of
412+ case map D.fromChars suggestions of
414413 [] ->
415414 "I cannot find any super similar exposed names. Maybe it is private?"
416415
@@ -430,8 +429,8 @@ toReport source err =
430429 NotFoundType region prefix name possibleNames ->
431430 notFound source region prefix name "type" possibleNames
432431
433− NotFoundCtor region prefix name possibleNames ->
434− notFound source region prefix name "constructor" possibleNames
432+ NotFoundVariant region prefix name possibleNames ->
433+ notFound source region prefix name "variant" possibleNames
435434
436435 NotFoundBinop region op locals ->
437436 if op == "===" then
@@ -454,7 +453,7 @@ toReport source err =
454453 [ D.reflow "Switch to (/=) instead."
455454 , D.toSimpleNote $
456455 "Our (/=) operator is supposed to look like a real “not equal” sign (≠). I hope that history will remember ("
457− ++ Name.toString op ++ ") as a weird and temporary choice."
456+ ++ Name.toChars op ++ ") as a weird and temporary choice."
458457 ]
459458 )
460459
@@ -491,8 +490,8 @@ toReport source err =
491490 else
492491 let
493492 suggestions =
494− map Name.toString $ take 2 $
495− Suggest.sort (Name.toString op) Name.toString (Set.toList locals)
493+ map Name.toChars $ take 2 $
494+ Suggest.sort (Name.toChars op) Name.toChars (Set.toList locals)
496495
497496 format altOp =
498497 D.green $ "(" <> altOp <> ")"
@@ -501,12 +500,12 @@ toReport source err =
501500 Report.toCodeSnippet source region Nothing
502501 (
503502 D.reflow $
504− "I do not recognize the (" ++ Name.toString op ++ ") operator."
503+ "I do not recognize the (" ++ Name.toChars op ++ ") operator."
505504 ,
506505 D.fillSep $
507506 ["Is","there","an","`import`","and","`exposing`","entry","for","it?"]
508507 ++
509− case map D.fromString suggestions of
508+ case map D.fromChars suggestions of
510509 [] ->
511510 []
512511
@@ -519,7 +518,7 @@ toReport source err =
519518 Report.toCodeSnippet source region Nothing
520519 (
521520 D.reflow $
522− "You can construct records by using `" <> Name.toString name
521+ "You can construct records by using `" <> Name.toChars name
523522 <> "` as a function, but it is not available in pattern matching like this:"
524523 ,
525524 D.reflow $
@@ -533,7 +532,7 @@ toReport source err =
533532 Report.toCodeSnippet source region Nothing
534533 (
535534 D.reflow $
536− "The `" <> Name.toString portName <> "` port is trying to transmit " <> aBadKindOfThing <> ":"
535+ "The `" <> Name.toChars portName <> "` port is trying to transmit " <> aBadKindOfThing <> ":"
537536 ,
538537 D.stack
539538 [ elaboration
@@ -570,14 +569,14 @@ toReport source err =
570569 "an unspecified type"
571570 ,
572571 D.reflow $
573− "But type variables like `" <> Name.toString name <> "` cannot flow through ports.\
572+ "But type variables like `" <> Name.toChars name <> "` cannot flow through ports.\
574573 \ I need to know exactly what type of data I am getting, so I can guarantee that\
575574 \ unexpected data cannot sneak in and crash the Elm program."
576575 )
577576
578577 UnsupportedType name ->
579578 (
580− "a `" <> Name.toString name <> "` value"
579+ "a `" <> Name.toChars name <> "` value"
581580 ,
582581 D.stack
583582 [ D.reflow $ "I cannot handle that. The types that CAN flow in and out of Elm include:"
@@ -611,7 +610,7 @@ toReport source err =
611610 case portProblem of
612611 CmdNoArg ->
613612 (
614− "The `" <> Name.toString name <> "` port cannot be just a command."
613+ "The `" <> Name.toChars name <> "` port cannot be just a command."
615614 ,
616615 D.reflow $
617616 "It can be (() -> Cmd msg) if you just need to trigger a JavaScript\
@@ -620,7 +619,7 @@ toReport source err =
620619
621620 CmdExtraArgs n ->
622621 (
623− "The `" <> Name.toString name <> "` port can only send ONE value out to JavaScript."
622+ "The `" <> Name.toChars name <> "` port can only send ONE value out to JavaScript."
624623 ,
625624 let
626625 theseItemsInSomething
@@ -634,7 +633,7 @@ toReport source err =
634633
635634 CmdBadMsg ->
636635 (
637− "The `" <> Name.toString name <> "` port cannot send any messages to the `update` function."
636+ "The `" <> Name.toChars name <> "` port cannot send any messages to the `update` function."
638637 ,
639638 D.reflow $
640639 "It must produce a (Cmd msg) type. Notice the lower case `msg` type\
@@ -643,13 +642,13 @@ toReport source err =
643642 )
644643
645644 SubBad ->
646− ( "There is something off about this `" <> Name.toString name <> "` port declaration."
645+ ( "There is something off about this `" <> Name.toChars name <> "` port declaration."
647646 ,
648647 D.stack
649648 [ D.reflow $
650649 "To receive messages from JavaScript, you need to define a port like this:"
651− , D.indent 4 $ D.dullyellow $ D.fromString $
652− "port " <> Name.toString name <> " : (Int -> msg) -> Sub msg"
650+ , D.indent 4 $ D.dullyellow $ D.fromChars $
651+ "port " <> Name.toChars name <> " : (Int -> msg) -> Sub msg"
653652 , D.reflow $
654653 "Now every time JS sends an `Int` to this port, it is converted to a `msg`.\
655654 \ And if you subscribe, those `msg` values will be piped into your `update`\
@@ -659,7 +658,7 @@ toReport source err =
659658
660659 NotCmdOrSub ->
661660 (
662− "I am confused about the `" <> Name.toString name <> "` port declaration."
661+ "I am confused about the `" <> Name.toChars name <> "` port declaration."
663662 ,
664663 D.reflow $
665664 "Ports need to produce a command (Cmd) or a subscription (Sub) but\
@@ -677,7 +676,7 @@ toReport source err =
677676 Can.TypedDef name _ _ _ _ -> name
678677
679678 makeTheory question details =
680− D.fillSep $ map (D.dullyellow . D.fromString) (words question) ++ map D.fromString (words details)
679+ D.fillSep $ map (D.dullyellow . D.fromChars) (words question) ++ map D.fromChars (words details)
681680 in
682681 case map toName cyclicValueDefs of
683682 [] ->
@@ -693,16 +692,16 @@ toReport source err =
693692 [] ->
694693 (
695694 D.reflow $
696− "The `" <> Name.toString name <> "` value is defined directly in terms of itself, causing an infinite loop."
695+ "The `" <> Name.toChars name <> "` value is defined directly in terms of itself, causing an infinite loop."
697696 ,
698697 D.stack
699698 [ makeTheory "Are you are trying to mutate a variable?" $
700− "Elm does not have mutation, so when I see " ++ Name.toString name
701− ++ " defined in terms of " ++ Name.toString name
699+ "Elm does not have mutation, so when I see " ++ Name.toChars name
700+ ++ " defined in terms of " ++ Name.toChars name
702701 ++ ", I treat it as a recursive definition. Try giving the new value a new name!"
703702 , makeTheory "Maybe you DO want a recursive value?" $
704− "To define " ++ Name.toString name ++ " we need to know what " ++ Name.toString name
705− ++ " is, so let’s expand it. Wait, but now we need to know what " ++ Name.toString name
703+ "To define " ++ Name.toChars name ++ " we need to know what " ++ Name.toChars name
704+ ++ " is, so let’s expand it. Wait, but now we need to know what " ++ Name.toChars name
706705 ++ " is, so let’s expand it... This will keep going infinitely!"
707706 , D.link "Hint"
708707 "The root problem is often a typo in some variable name, but I recommend reading"
@@ -714,11 +713,11 @@ toReport source err =
714713 names ->
715714 (
716715 D.reflow $
717− "The `" <> Name.toString name <> "` definition is causing a very tricky infinite loop."
716+ "The `" <> Name.toChars name <> "` definition is causing a very tricky infinite loop."
718717 ,
719718 D.stack
720719 [ D.reflow $
721− "The `" <> Name.toString name
720+ "The `" <> Name.toChars name
722721 <> "` value depends on itself through the following chain of definitions:"
723722 , D.cycle 4 (name:names)
724723 , D.link "Hint"
@@ -735,20 +734,20 @@ toReport source err =
735734 [] ->
736735 let
737736 makeTheory question details =
738− D.fillSep $ map (D.dullyellow . D.fromString) (words question) ++ map D.fromString (words details)
737+ D.fillSep $ map (D.dullyellow . D.fromChars) (words question) ++ map D.fromChars (words details)
739738 in
740739 (
741740 D.reflow $
742− "The `" <> Name.toString name <> "` value is defined directly in terms of itself, causing an infinite loop."
741+ "The `" <> Name.toChars name <> "` value is defined directly in terms of itself, causing an infinite loop."
743742 ,
744743 D.stack
745744 [ makeTheory "Are you are trying to mutate a variable?" $
746− "Elm does not have mutation, so when I see " ++ Name.toString name
747− ++ " defined in terms of " ++ Name.toString name
745+ "Elm does not have mutation, so when I see " ++ Name.toChars name
746+ ++ " defined in terms of " ++ Name.toChars name
748747 ++ ", I treat it as a recursive definition. Try giving the new value a new name!"
749748 , makeTheory "Maybe you DO want a recursive value?" $
750− "To define " ++ Name.toString name ++ " we need to know what " ++ Name.toString name
751− ++ " is, so let’s expand it. Wait, but now we need to know what " ++ Name.toString name
749+ "To define " ++ Name.toChars name ++ " we need to know what " ++ Name.toChars name
750+ ++ " is, so let’s expand it. Wait, but now we need to know what " ++ Name.toChars name
752751 ++ " is, so let’s expand it... This will keep going infinitely!"
753752 , D.link "Hint"
754753 "The root problem is often a typo in some variable name, but I recommend reading"
@@ -764,7 +763,7 @@ toReport source err =
764763 ,
765764 D.stack
766765 [ D.reflow $
767− "The `" <> Name.toString name
766+ "The `" <> Name.toChars name
768767 <> "` value depends on itself through the following chain of definitions:"
769768 , D.cycle 4 (name:names)
770769 , D.link "Hint"
@@ -780,7 +779,7 @@ toReport source err =
780779 ( "These variables cannot have the same name:"
781780 , advice
782781 )
783− ( D.reflow $ "The name `" <> Name.toString name <> "` is first defined here:"
782+ ( D.reflow $ "The name `" <> Name.toChars name <> "` is first defined here:"
784783 , "But then it is defined AGAIN over here:"
785784 , advice
786785 )
@@ -902,7 +901,7 @@ toReport source err =
902901 Report.toCodeSnippet source aliasRegion Nothing
903902 (
904903 D.reflow $
905− "Type alias `" <> Name.toString typeName <> "` has some type variable problems."
904+ "Type alias `" <> Name.toChars typeName <> "` has some type variable problems."
906905 ,
907906 D.stack
908907 [ D.fillSep $ theseAreUsed ++ butTheseAreUnused
@@ -921,7 +920,7 @@ toReport source err =
921920-- BAD TYPE VARIABLES
922921
923922
924−unboundTypeVars :: Code.Source -> R.Region -> [D.Doc] -> Name.Name -> [Name.Name] -> (Name.Name, R.Region) -> [(Name.Name, R.Region)] -> Report.Report
923+unboundTypeVars :: Code.Source -> A.Region -> [D.Doc] -> Name.Name -> [Name.Name] -> (Name.Name, A.Region) -> [(Name.Name, A.Region)] -> Report.Report
925924unboundTypeVars source declRegion tipe typeName allVars (unboundVar, varRegion) unboundVars =
926925 let
927926 backQuote name =
@@ -960,7 +959,7 @@ unboundTypeVars source declRegion tipe typeName allVars (unboundVar, varRegion)
960959 ++ map (D.green . D.fromName) (unboundVar : map fst unboundVars)
961960 ++ ["=", "..."]
962961 , D.reflow $
963− "Why? Well, imagine one `" ++ Name.toString typeName ++ "` where `" ++ Name.toString unboundVar ++
962+ "Why? Well, imagine one `" ++ Name.toChars typeName ++ "` where `" ++ Name.toChars unboundVar ++
964963 "` is an Int and another where it is a Bool. When we explicitly list the type\
965964 \ variables, the type checker can see that they are actually different types."
966965 ]
@@ -971,7 +970,7 @@ unboundTypeVars source declRegion tipe typeName allVars (unboundVar, varRegion)
971970-- NAME CLASH
972971
973972
974−nameClash :: Code.Source -> R.Region -> R.Region -> String -> Report.Report
973+nameClash :: Code.Source -> A.Region -> A.Region -> String -> Report.Report
975974nameClash source r1 r2 messageThatEndsWithPunctuation =
976975 Report.Report "NAME CLASH" r2 [] $
977976 Report.toCodePair source r1 r2
@@ -993,7 +992,7 @@ nameClash source r1 r2 messageThatEndsWithPunctuation =
993992-- AMBIGUOUS NAME
994993
995994
996−ambiguousName :: Code.Source -> R.Region -> Maybe Name.Name -> Name.Name -> [ModuleName.Canonical] -> String -> Report.Report
995+ambiguousName :: Code.Source -> A.Region -> Maybe Name.Name -> Name.Name -> [ModuleName.Canonical] -> String -> Report.Report
997996ambiguousName source region maybePrefix name possibleHomes thing =
998997 Report.Report "AMBIGUOUS NAME" region [] $
999998 Report.toCodeSnippet source region Nothing $
@@ -1007,12 +1006,12 @@ ambiguousName source region maybePrefix name possibleHomes thing =
10071006 if length possibleHomes == 2 then "both" else "all"
10081007 in
10091008 (
1010− D.reflow $ "This usage of `" ++ Name.toString name ++ "` is ambiguous."
1009+ D.reflow $ "This usage of `" ++ Name.toChars name ++ "` is ambiguous."
10111010 ,
10121011 D.stack
10131012 [ D.reflow $
10141013 "Check your imports. The following modules " ++ bothOrAll
1015− ++ " expose a `" ++ Name.toString name ++ "` " ++ thing ++ ":"
1014+ ++ " expose a `" ++ Name.toChars name ++ "` " ++ thing ++ ":"
10161015 , D.indent 4 $ D.vcat $ map homeToYellowDoc possibleHomes
10171016 , D.reflowLink "Read" "imports" "to learn how to clarify which one you want."
10181017 ]
@@ -1046,18 +1045,18 @@ ambiguousName source region maybePrefix name possibleHomes thing =
10461045-- NOT FOUND
10471046
10481047
1049−notFound :: Code.Source -> R.Region -> Maybe Name.Name -> Name.Name -> String -> PossibleNames -> Report.Report
1048+notFound :: Code.Source -> A.Region -> Maybe Name.Name -> Name.Name -> String -> PossibleNames -> Report.Report
10501049notFound source region maybePrefix name thing (PossibleNames locals quals) =
10511050 let
10521051 givenName =
1053− maybe Name.toString toQualString maybePrefix name
1052+ maybe Name.toChars toQualString maybePrefix name
10541053
10551054 possibleNames =
10561055 let
10571056 addQuals prefix localSet allNames =
10581057 Set.foldr (\x xs -> toQualString prefix x : xs) allNames localSet
10591058 in
1060− Map.foldrWithKey addQuals (map Name.toString (Set.toList locals)) quals
1059+ Map.foldrWithKey addQuals (map Name.toChars (Set.toList locals)) quals
10611060
10621061 nearbyNames =
10631062 take 4 (Suggest.sort givenName id possibleNames)
@@ -1073,7 +1072,7 @@ notFound source region maybePrefix name thing (PossibleNames locals quals) =
10731072 suggestions ->
10741073 D.stack
10751074 [ D.reflow yesSuggestionDetails
1076− , D.indent 4 $ D.vcat $ map D.dullyellow $ map D.fromString suggestions
1075+ , D.indent 4 $ D.vcat $ map D.dullyellow $ map D.fromChars suggestions
10771076 , D.link "Hint" "Read" "imports" "to see how `import` declarations work in Elm."
10781077 ]
10791078
@@ -1094,19 +1093,19 @@ notFound source region maybePrefix name thing (PossibleNames locals quals) =
10941093 case Map.lookup prefix quals of
10951094 Nothing ->
10961095 toDetails
1097− ("I cannot find a `" ++ Name.toString prefix ++ "` module. Is there an `import` for it?")
1098− ("I cannot find a `" ++ Name.toString prefix ++ "` import. These names seem close though:")
1096+ ("I cannot find a `" ++ Name.toChars prefix ++ "` module. Is there an `import` for it?")
1097+ ("I cannot find a `" ++ Name.toChars prefix ++ "` import. These names seem close though:")
10991098
11001099 Just _ ->
11011100 toDetails
1102− ("The `" ++ Name.toString prefix ++ "` module does not expose a `" ++ Name.toString name ++ "` " ++ thing ++ ".")
1103− ("The `" ++ Name.toString prefix ++ "` module does not expose a `" ++ Name.toString name ++ "` " ++ thing ++ ". These names seem close though:")
1101+ ("The `" ++ Name.toChars prefix ++ "` module does not expose a `" ++ Name.toChars name ++ "` " ++ thing ++ ".")
1102+ ("The `" ++ Name.toChars prefix ++ "` module does not expose a `" ++ Name.toChars name ++ "` " ++ thing ++ ". These names seem close though:")
11041103 )
11051104
11061105
11071106toQualString :: Name.Name -> Name.Name -> String
11081107toQualString prefix name =
1109− Name.toString prefix ++ "." ++ Name.toString name
1108+ Name.toChars prefix ++ "." ++ Name.toChars name
11101109
11111110
11121111
@@ -1200,7 +1199,7 @@ modHint =
12001199-- ARG MISMATCH
12011200
12021201
1203−_argMismatchReport :: Code.Source -> R.Region -> String -> Name.Name -> Int -> Int -> Report.Report
1202+_argMismatchReport :: Code.Source -> A.Region -> String -> Name.Name -> Int -> Int -> Report.Report
12041203_argMismatchReport source region kind name expected actual =
12051204 let
12061205 numArgs =
@@ -1212,7 +1211,7 @@ _argMismatchReport source region kind name expected actual =
12121211 Report.toCodeSnippet source region Nothing
12131212 (
12141213 D.reflow $
1215− kind <> " " <> Name.toString name <> " has " <> numArgs <> "."
1214+ kind <> " " <> Name.toChars name <> " has " <> numArgs <> "."
12161215 ,
12171216 D.reflow $
12181217 "Expecting " <> show expected <> ", but got " <> show actual <> "."
@@ -1223,7 +1222,7 @@ _argMismatchReport source region kind name expected actual =
12231222-- BAD ALIAS RECURSION
12241223
12251224
1226−aliasRecursionReport :: Code.Source -> R.Region -> Name.Name -> [Name.Name] -> Src.Type -> [Name.Name] -> Report.Report
1225+aliasRecursionReport :: Code.Source -> A.Region -> Name.Name -> [Name.Name] -> Src.Type -> [Name.Name] -> Report.Report
12271226aliasRecursionReport source region name args tipe others =
12281227 case others of
12291228 [] ->