on master help sign in
Change "Ctor" to "Variant" / transition off Reporting.Region and Data.Text
commitfe41b26a331bb19ad53a8a8decd2a9c058d94614 authorEvan Czaplicki <evancz@users.noreply.github.com> dateFri 28 Dec 2018, 17:14 (8 years ago) parent83cd588
9 files changed+266−276
compiler/src/Reporting/Error/Canonicalize.hs+125−126 compiler/src/Reporting/Error/Docs.hs+16−16 compiler/src/Reporting/Error/Main.hs+6−6 compiler/src/Reporting/Error/Type.hs+58−58 compiler/src/Reporting/Render/Code.hs+32−39 compiler/src/Reporting/Render/Type/Localizer.hs+11−13 compiler/src/Reporting/Report.hs+5−5 compiler/src/Reporting/Warning.hs+10−10 compiler/src/Type/Error.hs+3−3
compiler/src/Reporting/Error/Canonicalize.hs+125−126
@@ -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 [] ->
compiler/src/Reporting/Error/Docs.hs+16−16
@@ -9,22 +9,22 @@ module Reporting.Error.Docs
99
1010import qualified Data.Name as Name
1111
12+import qualified Reporting.Annotation as A
1213import Reporting.Doc ((<>))
1314import qualified Reporting.Doc as D
14−import qualified Reporting.Region as R
1515import qualified Reporting.Render.Code as Code
1616import qualified Reporting.Report as Report
1717
1818
1919
2020data Error
21− = NoDocs R.Region
22− | ImplicitExposing R.Region
23− | Duplicate Name.Name R.Region R.Region
24− | OnlyInDocs Name.Name R.Region
25− | OnlyInExports Name.Name R.Region
26− | NoComment Name.Name R.Region
27− | NoAnnotation Name.Name R.Region
21+ = NoDocs A.Region
22+ | ImplicitExposing A.Region
23+ | Duplicate Name.Name A.Region A.Region
24+ | OnlyInDocs Name.Name A.Region
25+ | OnlyInExports Name.Name A.Region
26+ | NoComment Name.Name A.Region
27+ | NoAnnotation Name.Name A.Region
2828
2929
3030
@@ -66,14 +66,14 @@ toReport source err =
6666 Report.toCodePair source r1 r2
6767 (
6868 D.reflow $
69− "There can only be one `" <> Name.toString name
69+ "There can only be one `" <> Name.toChars name
7070 <> "` in your module documentation, but it is listed twice:"
7171 ,
7272 "Remove one of them!"
7373 )
7474 (
7575 D.reflow $
76− "There can only be one `" <> Name.toString name
76+ "There can only be one `" <> Name.toChars name
7777 <> "` in your module documentation, but I see two. One here:"
7878 ,
7979 "And another one over here:"
@@ -86,12 +86,12 @@ toReport source err =
8686 Report.toCodeSnippet source region Nothing
8787 (
8888 D.reflow $
89− "I do not see `" <> Name.toString name
89+ "I do not see `" <> Name.toChars name
9090 <> "` in the `exposing` list, but it is in your module documentation:"
9191 ,
9292 D.reflow $
9393 "Does it need to be added to the `exposing` list as well? Or maybe you removed `"
94− <> Name.toString name <> "` and forgot to delete it here?"
94+ <> Name.toChars name <> "` and forgot to delete it here?"
9595 )
9696
9797 OnlyInExports name region ->
@@ -99,12 +99,12 @@ toReport source err =
9999 Report.toCodeSnippet source region Nothing
100100 (
101101 D.reflow $
102− "I do not see `" <> Name.toString name
102+ "I do not see `" <> Name.toChars name
103103 <> "` in your module documentation, but it is in your `exposing` list:"
104104 ,
105105 D.stack
106106 [ D.reflow $
107− "Add a line like `@docs " <> Name.toString name
107+ "Add a line like `@docs " <> Name.toChars name
108108 <> "` to your module documentation!"
109109 , D.link "Note" "See" "docs" "for more guidance on writing high quality docs."
110110 ]
@@ -115,7 +115,7 @@ toReport source err =
115115 Report.toCodeSnippet source region Nothing
116116 (
117117 D.reflow $
118− "The `" <> Name.toString name <> "` definition does not have a documentation comment."
118+ "The `" <> Name.toChars name <> "` definition does not have a documentation comment."
119119 ,
120120 D.stack
121121 [ D.reflow $
@@ -129,7 +129,7 @@ toReport source err =
129129 Report.toCodeSnippet source region Nothing
130130 (
131131 D.reflow $
132− "The `" <> Name.toString name <> "` definition does not have a type annotation."
132+ "The `" <> Name.toChars name <> "` definition does not have a type annotation."
133133 ,
134134 D.stack
135135 [ D.reflow $
compiler/src/Reporting/Error/Main.hs+6−6
@@ -10,9 +10,9 @@ module Reporting.Error.Main
1010import qualified Data.Name as Name
1111
1212import qualified AST.Canonical as Can
13+import qualified Reporting.Annotation as A
1314import qualified Reporting.Doc as D
1415import qualified Reporting.Error.Canonicalize as E
15−import qualified Reporting.Region as R
1616import qualified Reporting.Render.Code as Code
1717import qualified Reporting.Render.Type as RT
1818import qualified Reporting.Render.Type.Localizer as L
@@ -24,9 +24,9 @@ import qualified Reporting.Report as Report
2424
2525
2626data Error
27− = BadType R.Region Can.Type
28− | BadCycle R.Region [Name.Name]
29− | BadFlags R.Region Can.Type E.InvalidPayload
27+ = BadType A.Region Can.Type
28+ | BadCycle A.Region [Name.Name]
29+ | BadFlags A.Region Can.Type E.InvalidPayload
3030
3131
3232
@@ -101,14 +101,14 @@ toReport localizer source err =
101101 "an unspecified type"
102102 ,
103103 D.reflow $
104− "But type variables like `" ++ Name.toString name ++ "` cannot be given as flags.\
104+ "But type variables like `" ++ Name.toChars name ++ "` cannot be given as flags.\
105105 \ I need to know exactly what type of data I am getting, so I can guarantee that\
106106 \ unexpected data cannot sneak in and crash the Elm program."
107107 )
108108
109109 E.UnsupportedType name ->
110110 (
111− "a `" ++ Name.toString name ++ "` value"
111+ "a `" ++ Name.toChars name ++ "` value"
112112 ,
113113 D.stack
114114 [ D.reflow $ "I cannot handle that. The types that CAN be in flags include:"
compiler/src/Reporting/Error/Type.hs+58−58
@@ -26,8 +26,8 @@ import qualified Data.Name as Name
2626
2727import qualified AST.Canonical as Can
2828import qualified Data.Index as Index
29+import qualified Reporting.Annotation as A
2930import qualified Reporting.Doc as D
30−import qualified Reporting.Region as R
3131import qualified Reporting.Render.Code as Code
3232import qualified Reporting.Render.Type as RT
3333import qualified Reporting.Render.Type.Localizer as L
@@ -41,9 +41,9 @@ import qualified Type.Error as T
4141
4242
4343data Error
44− = BadExpr R.Region Category T.Type (Expected T.Type)
45− | BadPattern R.Region PCategory T.Type (PExpected T.Type)
46− | InfiniteType R.Region Name.Name T.Type
44+ = BadExpr A.Region Category T.Type (Expected T.Type)
45+ | BadPattern A.Region PCategory T.Type (PExpected T.Type)
46+ | InfiniteType A.Region Name.Name T.Type
4747
4848
4949
@@ -52,7 +52,7 @@ data Error
5252
5353data Expected tipe
5454 = NoExpectation tipe
55− | FromContext R.Region Context tipe
55+ | FromContext A.Region Context tipe
5656 | FromAnnotation Name.Name Int SubContext tipe
5757
5858
@@ -66,7 +66,7 @@ data Context
6666 | CaseBranch Index.ZeroBased
6767 | CallArity MaybeName Int
6868 | CallArg MaybeName Index.ZeroBased
69− | RecordAccess R.Region (Maybe Name.Name) R.Region Name.Name
69+ | RecordAccess A.Region (Maybe Name.Name) A.Region Name.Name
7070 | RecordUpdateKeys Name.Name (Map.Map Name.Name Can.FieldUpdate)
7171 | RecordUpdateValue Name.Name
7272 | Destructure
@@ -112,7 +112,7 @@ data Category
112112
113113data PExpected tipe
114114 = PNoExpectation tipe
115− | PFromContext R.Region PContext tipe
115+ | PFromContext A.Region PContext tipe
116116
117117
118118data PContext
@@ -183,7 +183,7 @@ toReport source localizer err =
183183-- TO PATTERN REPORT
184184
185185
186−toPatternReport :: Code.Source -> L.Localizer -> R.Region -> PCategory -> T.Type -> PExpected T.Type -> Report.Report
186+toPatternReport :: Code.Source -> L.Localizer -> A.Region -> PCategory -> T.Type -> PExpected T.Type -> Report.Report
187187toPatternReport source localizer patternRegion category tipe expected =
188188 Report.Report "TYPE MISMATCH" patternRegion [] $
189189 case expected of
@@ -201,10 +201,10 @@ toPatternReport source localizer patternRegion category tipe expected =
201201 case context of
202202 PTypedArg name index ->
203203 ( D.reflow $
204− "The " <> D.ordinal index <> " argument to `" <> Name.toString name <> "` is weird."
204+ "The " <> D.ordinal index <> " argument to `" <> Name.toChars name <> "` is weird."
205205 , patternTypeComparison localizer tipe expectedType
206206 (addPatternCategory "The argument is a pattern that matches" category)
207− ( "But the type annotation on `" <> Name.toString name
207+ ( "But the type annotation on `" <> Name.toChars name
208208 <> "` says the " <> D.ordinal index <> " argument should be:"
209209 )
210210 []
@@ -238,10 +238,10 @@ toPatternReport source localizer patternRegion category tipe expected =
238238
239239 PCtorArg name index ->
240240 ( D.reflow $
241− "The " <> D.ordinal index <> " argument to `" <> Name.toString name <> "` is weird."
241+ "The " <> D.ordinal index <> " argument to `" <> Name.toChars name <> "` is weird."
242242 , patternTypeComparison localizer tipe expectedType
243243 (addPatternCategory "It is trying to match" category)
244− ( "But `" <> Name.toString name <> "` needs its "
244+ ( "But `" <> Name.toChars name <> "` needs its "
245245 <> D.ordinal index <> " argument to be:"
246246 )
247247 []
@@ -299,7 +299,7 @@ addPatternCategory iAmTryingToMatch category =
299299 PUnit -> " unit values:"
300300 PTuple -> " tuples of type:"
301301 PList -> " lists of type:"
302− PCtor name -> " `" <> Name.toString name <> "` values of type:"
302+ PCtor name -> " `" <> Name.toChars name <> "` values of type:"
303303 PInt -> " integers:"
304304 PStr -> " strings:"
305305 PChr -> " characters:"
@@ -343,10 +343,10 @@ loneType localizer actual expected iAmSeeing furtherDetails =
343343addCategory :: String -> Category -> String
344344addCategory thisIs category =
345345 case category of
346− Local name -> "This `" <> Name.toString name <> "` value is a:"
347− Foreign name -> "This `" <> Name.toString name <> "` value is a:"
348− Access field -> "The value at ." <> Name.toString field <> " is a:"
349− Accessor field -> "This ." <> Name.toString field <> " field access function has type:"
346+ Local name -> "This `" <> Name.toChars name <> "` value is a:"
347+ Foreign name -> "This `" <> Name.toChars name <> "` value is a:"
348+ Access field -> "The value at ." <> Name.toChars field <> " is a:"
349+ Accessor field -> "This ." <> Name.toChars field <> " field access function has type:"
350350 If -> "This `if` expression produces:"
351351 Case -> "This `case` expression produces:"
352352 List -> thisIs <> " a list of type:"
@@ -363,8 +363,8 @@ addCategory thisIs category =
363363 CallResult maybeName ->
364364 case maybeName of
365365 NoName -> thisIs <> ":"
366− FuncName name -> "This `" <> Name.toString name <> "` call produces:"
367− CtorName name -> "This `" <> Name.toString name <> "` call produces:"
366+ FuncName name -> "This `" <> Name.toChars name <> "` call produces:"
367+ CtorName name -> "This `" <> Name.toChars name <> "` call produces:"
368368 OpName _ -> thisIs <> ":"
369369
370370
@@ -462,11 +462,11 @@ problemToHint problem =
462462 T.FlexSuper s _ -> badRigidVar x (toASuperThing s)
463463 T.RigidVar y -> badDoubleRigid x y
464464 T.RigidSuper _ y -> badDoubleRigid x y
465− T.Type _ n _ -> badRigidVar x ("a `" ++ Name.toString n ++ "` value")
465+ T.Type _ n _ -> badRigidVar x ("a `" ++ Name.toChars n ++ "` value")
466466 T.Record _ _ -> badRigidVar x "a record"
467467 T.Unit -> badRigidVar x "a unit value"
468468 T.Tuple _ _ _ -> badRigidVar x "a tuple"
469− T.Alias _ n _ _ -> badRigidVar x ("a `" ++ Name.toString n ++ "` value")
469+ T.Alias _ n _ _ -> badRigidVar x ("a `" ++ Name.toChars n ++ "` value")
470470
471471 T.BadRigidSuper super x tipe ->
472472 case tipe of
@@ -477,11 +477,11 @@ problemToHint problem =
477477 T.FlexSuper s _ -> badRigidSuper super (toASuperThing s)
478478 T.RigidVar y -> badDoubleRigid x y
479479 T.RigidSuper _ y -> badDoubleRigid x y
480− T.Type _ n _ -> badRigidSuper super ("a `" ++ Name.toString n ++ "` value")
480+ T.Type _ n _ -> badRigidSuper super ("a `" ++ Name.toChars n ++ "` value")
481481 T.Record _ _ -> badRigidSuper super "a record"
482482 T.Unit -> badRigidSuper super "a unit value"
483483 T.Tuple _ _ _ -> badRigidSuper super "a tuple"
484− T.Alias _ n _ _ -> badRigidSuper super ("a `" ++ Name.toString n ++ "` value")
484+ T.Alias _ n _ _ -> badRigidSuper super ("a `" ++ Name.toChars n ++ "` value")
485485
486486 T.FieldsMissing fields ->
487487 case map (D.green . D.fromName) fields of
@@ -499,7 +499,7 @@ problemToHint problem =
499499
500500
501501 T.FieldTypo typo possibilities ->
502− case Suggest.sort (Name.toString typo) Name.toString possibilities of
502+ case Suggest.sort (Name.toChars typo) Name.toChars possibilities of
503503 [] ->
504504 []
505505
@@ -522,7 +522,7 @@ problemToHint problem =
522522badRigidVar :: Name.Name -> String -> [D.Doc]
523523badRigidVar name aThing =
524524 [ D.toSimpleHint $
525− "Your type annotation uses type variable `" ++ Name.toString name ++
525+ "Your type annotation uses type variable `" ++ Name.toChars name ++
526526 "` which means ANY type of value can flow through, but your code is saying it specifically wants "
527527 ++ aThing ++ ". Maybe change your type annotation to\
528528 \ be more specific? Maybe change the code to be more general?"
@@ -533,7 +533,7 @@ badRigidVar name aThing =
533533badDoubleRigid :: Name.Name -> Name.Name -> [D.Doc]
534534badDoubleRigid x y =
535535 [ D.toSimpleHint $
536− "Your type annotation uses `" ++ Name.toString x ++ "` and `" ++ Name.toString y ++
536+ "Your type annotation uses `" ++ Name.toChars x ++ "` and `" ++ Name.toChars y ++
537537 "` as separate type variables. Your code seems to be saying they are the\
538538 \ same though. Maybe they should be the same in your type annotation?\
539539 \ Maybe your code uses them in a weird way?"
@@ -625,7 +625,7 @@ badFlexFlexSuper s1 s2 =
625625-- TO EXPR REPORT
626626
627627
628−toExprReport :: Code.Source -> L.Localizer -> R.Region -> Category -> T.Type -> Expected T.Type -> Report.Report
628+toExprReport :: Code.Source -> L.Localizer -> A.Region -> Category -> T.Type -> Expected T.Type -> Report.Report
629629toExprReport source localizer exprRegion category tipe expected =
630630 case expected of
631631 NoExpectation expectedType ->
@@ -644,7 +644,7 @@ toExprReport source localizer exprRegion category tipe expected =
644644 case subContext of
645645 TypedIfBranch index -> D.ordinal index <> " branch of this `if` expression:"
646646 TypedCaseBranch index -> D.ordinal index <> " branch of this `case` expression:"
647− TypedBody -> "body of the `" <> Name.toString name <> "` definition:"
647+ TypedBody -> "body of the `" <> Name.toChars name <> "` definition:"
648648
649649 itIs =
650650 case subContext of
@@ -657,7 +657,7 @@ toExprReport source localizer exprRegion category tipe expected =
657657 ( D.reflow ("Something is off with the " <> thing)
658658 , typeComparison localizer tipe expectedType
659659 (addCategory itIs category)
660− ("But the type annotation on `" <> Name.toString name <> "` says it should be:")
660+ ("But the type annotation on `" <> Name.toChars name <> "` says it should be:")
661661 []
662662 )
663663
@@ -769,9 +769,9 @@ toExprReport source localizer exprRegion category tipe expected =
769769 thisValue =
770770 case maybeFuncName of
771771 NoName -> "This value"
772− FuncName name -> "The `" <> Name.toString name <> "` value"
773− CtorName name -> "The `" <> Name.toString name <> "` value"
774− OpName op -> "The (" <> Name.toString op <> ") operator"
772+ FuncName name -> "The `" <> Name.toChars name <> "` value"
773+ CtorName name -> "The `" <> Name.toChars name <> "` value"
774+ OpName op -> "The (" <> Name.toChars op <> ") operator"
775775 in
776776 ( D.reflow $ thisValue <> " is not a function, but it was given " <> D.args numGivenArgs <> "."
777777 , D.reflow $ "Are there any missing commas? Or missing parentheses?"
@@ -782,9 +782,9 @@ toExprReport source localizer exprRegion category tipe expected =
782782 thisFunction =
783783 case maybeFuncName of
784784 NoName -> "This function"
785− FuncName name -> "The `" <> Name.toString name <> "` function"
786− CtorName name -> "The `" <> Name.toString name <> "` constructor"
787− OpName op -> "The (" <> Name.toString op <> ") operator"
785+ FuncName name -> "The `" <> Name.toChars name <> "` function"
786+ CtorName name -> "The `" <> Name.toChars name <> "` constructor"
787+ OpName op -> "The (" <> Name.toChars op <> ") operator"
788788 in
789789 ( D.reflow $ thisFunction <> " expects " <> D.args n <> ", but it got " <> show numGivenArgs <> " instead."
790790 , D.reflow $ "Are there any missing commas? Or missing parentheses?"
@@ -797,9 +797,9 @@ toExprReport source localizer exprRegion category tipe expected =
797797 thisFunction =
798798 case maybeFuncName of
799799 NoName -> "this function"
800− FuncName name -> "`" <> Name.toString name <> "`"
801− CtorName name -> "`" <> Name.toString name <> "`"
802− OpName op -> "(" <> Name.toString op <> ")"
800+ FuncName name -> "`" <> Name.toChars name <> "`"
801+ CtorName name -> "`" <> Name.toChars name <> "`"
802+ OpName op -> "(" <> Name.toChars op <> ")"
803803 in
804804 mismatch
805805 ( Just exprRegion
@@ -823,9 +823,9 @@ toExprReport source localizer exprRegion category tipe expected =
823823 custom (Just fieldRegion)
824824 ( D.reflow $
825825 "This "
826− <> maybe "" (\n -> "`" <> Name.toString n <> "`") maybeName
827− <> " record does not have a `" <> Name.toString field <> "` field:"
828− , case Suggest.sort (Name.toString field) (Name.toString . fst) (Map.toList fields) of
826+ <> maybe "" (\n -> "`" <> Name.toChars n <> "`") maybeName
827+ <> " record does not have a `" <> Name.toChars field <> "` field:"
828+ , case Suggest.sort (Name.toChars field) (Name.toChars . fst) (Map.toList fields) of
829829 [] ->
830830 D.reflow "In fact, it is a record with NO fields!"
831831
@@ -833,7 +833,7 @@ toExprReport source localizer exprRegion category tipe expected =
833833 D.stack
834834 [ D.reflow $
835835 "This is usually a typo. Here are the "
836− <> maybe "" (\n -> "`" <> Name.toString n <> "`") maybeName
836+ <> maybe "" (\n -> "`" <> Name.toChars n <> "`") maybeName
837837 <> " fields that are most similar:"
838838 , toNearbyRecord localizer f fs ext
839839 , D.fillSep
@@ -863,7 +863,7 @@ toExprReport source localizer exprRegion category tipe expected =
863863 mismatch
864864 ( Nothing
865865 , "Something is off with this record update:"
866− , "The `" <> Name.toString record <> "` record is"
866+ , "The `" <> Name.toChars record <> "` record is"
867867 , "But this update needs it to be compatable with:"
868868 , [ D.reflow
869869 "Do you mind creating an <http://sscce.org/> that produces this error message and\
@@ -874,13 +874,13 @@ toExprReport source localizer exprRegion category tipe expected =
874874
875875 Just (field, Can.FieldUpdate fieldRegion _) ->
876876 let
877− rStr = "`" <> Name.toString record <> "`"
878− fStr = "`" <> Name.toString field <> "`"
877+ rStr = "`" <> Name.toChars record <> "`"
878+ fStr = "`" <> Name.toChars field <> "`"
879879 in
880880 custom (Just fieldRegion)
881881 ( D.reflow $
882882 "The " <> rStr <> " record does not have a " <> fStr <> " field:"
883− , case Suggest.sort (Name.toString field) (Name.toString . fst) (Map.toList actualFields) of
883+ , case Suggest.sort (Name.toChars field) (Name.toChars . fst) (Map.toList actualFields) of
884884 [] ->
885885 D.reflow $ "In fact, " <> rStr <> " is a record with NO fields!"
886886
@@ -908,8 +908,8 @@ toExprReport source localizer exprRegion category tipe expected =
908908 RecordUpdateValue field ->
909909 mismatch
910910 ( Just exprRegion
911− , "I cannot update the `" <> Name.toString field <> "` field like this:"
912− , "You are trying to update `" <> Name.toString field <> "` to be"
911+ , "I cannot update the `" <> Name.toChars field <> "` field like this:"
912+ , "You are trying to update `" <> Name.toChars field <> "` to be"
913913 , "But it should be:"
914914 , [ D.toSimpleNote
915915 "The record update syntax does not allow you to change the type of fields.\
@@ -1008,10 +1008,10 @@ opLeftToDocs localizer category op tipe expected =
10081008
10091009 _ ->
10101010 ( D.reflow $
1011− "The left argument of (" <> Name.toString op <> ") is causing problems:"
1011+ "The left argument of (" <> Name.toChars op <> ") is causing problems:"
10121012 , typeComparison localizer tipe expected
10131013 (addCategory "The left argument is" category)
1014− ("But (" <> Name.toString op <> ") needs the left argument to be:")
1014+ ("But (" <> Name.toChars op <> ") needs the left argument to be:")
10151015 []
10161016 )
10171017
@@ -1103,12 +1103,12 @@ badOpRightFallback :: L.Localizer -> Category -> Name.Name -> T.Type -> T.Type -
11031103badOpRightFallback localizer category op tipe expected =
11041104 EmphRight
11051105 ( D.reflow $
1106− "The right argument of (" <> Name.toString op <> ") is causing problems."
1106+ "The right argument of (" <> Name.toChars op <> ") is causing problems."
11071107 , typeComparison localizer tipe expected
11081108 (addCategory "The right argument is" category)
1109− ("But (" <> Name.toString op <> ") needs the right argument to be:")
1109+ ("But (" <> Name.toChars op <> ") needs the right argument to be:")
11101110 [ D.toSimpleHint $
1111− "With operators like (" ++ Name.toString op ++ ") I always check the left\
1111+ "With operators like (" ++ Name.toChars op ++ ") I always check the left\
11121112 \ side first. If it seems fine, I assume it is correct and check the right\
11131113 \ side. So the problem may be in how the left and right arguments interact!"
11141114 ]
@@ -1318,7 +1318,7 @@ badCast :: Name.Name -> ThisThenThat -> RightDocs
13181318badCast op thisThenThat =
13191319 EmphBoth
13201320 ( D.reflow $
1321− "I need both sides of (" <> Name.toString op <> ") to be the exact same type. Both Int or both Float."
1321+ "I need both sides of (" <> Name.toChars op <> ") to be the exact same type. Both Int or both Float."
13221322 , let
13231323 anInt = ["an", D.dullyellow "Int"]
13241324 aFloat = ["a", D.dullyellow "Float"]
@@ -1405,7 +1405,7 @@ badMath localizer category operation direction op tipe expected otherHints =
14051405 loneType localizer tipe expected
14061406 (D.reflow (addCategory ("The " <> direction <> " side of (" <> op <> ") is") category))
14071407 ( [ D.fillSep
1408− ["But","(" <> D.fromString op <> ")","only","works","with"
1408+ ["But","(" <> D.fromChars op <> ")","only","works","with"
14091409 ,D.dullyellow "Int","and",D.dullyellow "Float","values."
14101410 ]
14111411 ]
@@ -1513,7 +1513,7 @@ badCompLeft localizer category op direction tipe expected =
15131513 loneType localizer tipe expected
15141514 (D.reflow (addCategory ("The " <> direction <> " side of (" <> op <> ") is") category))
15151515 [ D.fillSep
1516− ["But","(" <> D.fromString op <> ")","only","works","on"
1516+ ["But","(" <> D.fromChars op <> ")","only","works","on"
15171517 ,D.dullyellow "Int" <> ","
15181518 ,D.dullyellow "Float" <> ","
15191519 ,D.dullyellow "Char" <> ","
@@ -1571,13 +1571,13 @@ badEquality localizer op tipe expected =
15711571-- INFINITE TYPES
15721572
15731573
1574−toInfiniteReport :: Code.Source -> L.Localizer -> R.Region -> Name.Name -> T.Type -> Report.Report
1574+toInfiniteReport :: Code.Source -> L.Localizer -> A.Region -> Name.Name -> T.Type -> Report.Report
15751575toInfiniteReport source localizer region name overallType =
15761576 Report.Report "INFINITE TYPE" region [] $
15771577 Report.toCodeSnippet source region Nothing
15781578 (
15791579 D.reflow $
1580− "I am inferring a weird self-referential type for " <> Name.toString name <> ":"
1580+ "I am inferring a weird self-referential type for " <> Name.toChars name <> ":"
15811581 ,
15821582 D.stack
15831583 [ D.reflow $
compiler/src/Reporting/Render/Code.hs+32−39
@@ -11,11 +11,11 @@ module Reporting.Render.Code
1111
1212
1313import qualified Data.List as List
14−import qualified Data.Text as Text
14+import Data.Word (Word16)
1515
16−import Reporting.Doc (Doc, (<>))
16+import qualified Reporting.Annotation as A
1717import qualified Reporting.Doc as D
18−import qualified Reporting.Region as R
18+import Reporting.Doc (Doc)
1919
2020
2121
@@ -23,13 +23,13 @@ import qualified Reporting.Region as R
2323
2424
2525newtype Source =
26− Source [(Int, Text.Text)]
26+ Source [(Word16, String)]
2727
2828
29−toSource :: Text.Text -> Source
29+toSource :: String -> Source
3030toSource source =
3131 Source $ zip [1..] $
32− Text.lines source ++ [Text.empty]
32+ lines source ++ [""]
3333
3434
3535
@@ -41,16 +41,13 @@ toSource source =
4141 f a
4242
4343
44−render :: Source -> R.Region -> Maybe R.Region -> Doc
45−render (Source sourceLines) region@(R.Region start end) maybeSubRegion =
44+render :: Source -> A.Region -> Maybe A.Region -> Doc
45+render (Source sourceLines) region@(A.Region (A.Position startLine _) (A.Position endLine _)) maybeSubRegion =
4646 let
47− (R.Position startLine _) = start
48− (R.Position endLine _) = end
49−
5047 relevantLines =
5148 sourceLines
52− |> drop (startLine - 1)
53− |> take (1 + endLine - startLine)
49+ |> drop (fromIntegral (startLine - 1))
50+ |> take (fromIntegral (1 + endLine - startLine))
5451
5552 width =
5653 length (show (fst (last relevantLines)))
@@ -66,40 +63,36 @@ render (Source sourceLines) region@(R.Region start end) maybeSubRegion =
6663 drawLines False width smallerRegion relevantLines underline
6764
6865
69−makeUnderline :: Int -> Int -> R.Region -> Maybe Doc
70−makeUnderline width realEndLine (R.Region (R.Position start c1) (R.Position end c2)) =
66+makeUnderline :: Int -> Word16 -> A.Region -> Maybe Doc
67+makeUnderline width realEndLine (A.Region (A.Position start c1) (A.Position end c2)) =
7168 if start /= end || end < realEndLine then
7269 Nothing
7370
7471 else
7572 let
76− spaces = replicate (c1 + width + 1) ' '
77− zigzag = replicate (max 1 (c2 - c1)) '^'
73+ spaces = replicate (fromIntegral c1 + width + 1) ' '
74+ zigzag = replicate (max 1 (fromIntegral (c2 - c1))) '^'
7875 in
79− Just (D.fromString spaces <> D.dullred (D.fromString zigzag))
76+ Just (D.fromChars spaces <> D.dullred (D.fromChars zigzag))
8077
8178
82−drawLines :: Bool -> Int -> R.Region -> [(Int, Text.Text)] -> Doc -> Doc
83−drawLines addZigZag width (R.Region start end) sourceLines finalLine =
84− let
85− (R.Position startLine _) = start
86− (R.Position endLine _) = end
87− in
79+drawLines :: Bool -> Int -> A.Region -> [(Word16, String)] -> Doc -> Doc
80+drawLines addZigZag width (A.Region (A.Position startLine _) (A.Position endLine _)) sourceLines finalLine =
8881 D.vcat $
8982 map (drawLine addZigZag width startLine endLine) sourceLines
9083 ++ [finalLine]
9184
9285
93−drawLine :: Bool -> Int -> Int -> Int -> (Int, Text.Text) -> Doc
86+drawLine :: Bool -> Int -> Word16 -> Word16 -> (Word16, String) -> Doc
9487drawLine addZigZag width startLine endLine (n, line) =
95− addLineNumber addZigZag width startLine endLine n (D.fromText line)
88+ addLineNumber addZigZag width startLine endLine n (D.fromChars line)
9689
9790
98−addLineNumber :: Bool -> Int -> Int -> Int -> Int -> Doc -> Doc
91+addLineNumber :: Bool -> Int -> Word16 -> Word16 -> Word16 -> Doc -> Doc
9992addLineNumber addZigZag width start end n line =
10093 let
10194 number =
102− if n < 0 then " " else show n
95+ show n
10396
10497 lineNumber =
10598 replicate (width - length number) ' ' ++ number ++ "|"
@@ -110,7 +103,7 @@ addLineNumber addZigZag width start end n line =
110103 else
111104 " "
112105 in
113− D.fromString lineNumber <> spacer <> line
106+ D.fromChars lineNumber <> spacer <> line
114107
115108
116109
@@ -122,27 +115,27 @@ data CodePair
122115 | TwoChunks Doc Doc
123116
124117
125−renderPair :: Source -> R.Region -> R.Region -> CodePair
118+renderPair :: Source -> A.Region -> A.Region -> CodePair
126119renderPair source@(Source sourceLines) region1 region2 =
127120 let
128− (R.Region (R.Position startRow1 startCol1) (R.Position endRow1 endCol1)) = region1
129− (R.Region (R.Position startRow2 startCol2) (R.Position endRow2 endCol2)) = region2
121+ (A.Region (A.Position startRow1 startCol1) (A.Position endRow1 endCol1)) = region1
122+ (A.Region (A.Position startRow2 startCol2) (A.Position endRow2 endCol2)) = region2
130123 in
131124 if startRow1 == endRow1 && endRow1 == startRow2 && startRow2 == endRow2 then
132125 let
133126 lineNumber = show startRow1
134− spaces1 = replicate (startCol1 + length lineNumber + 1) ' '
135− zigzag1 = replicate (endCol1 - startCol1) '^'
136− spaces2 = replicate (startCol2 - endCol1) ' '
137− zigzag2 = replicate (endCol2 - startCol2) '^'
127+ spaces1 = replicate (fromIntegral startCol1 + length lineNumber + 1) ' '
128+ zigzag1 = replicate (fromIntegral (endCol1 - startCol1)) '^'
129+ spaces2 = replicate (fromIntegral (startCol2 - endCol1)) ' '
130+ zigzag2 = replicate (fromIntegral (endCol2 - startCol2)) '^'
138131
139132 (Just line) = List.lookup startRow1 sourceLines
140133 in
141134 OneLine $
142135 D.vcat
143− [ D.fromString lineNumber <> "| " <> D.fromText line
144− , D.fromString spaces1 <> D.dullred (D.fromString zigzag1) <>
145− D.fromString spaces2 <> D.dullred (D.fromString zigzag2)
136+ [ D.fromChars lineNumber <> "| " <> D.fromChars line
137+ , D.fromChars spaces1 <> D.dullred (D.fromChars zigzag1) <>
138+ D.fromChars spaces2 <> D.dullred (D.fromChars zigzag2)
146139 ]
147140
148141 else
compiler/src/Reporting/Render/Type/Localizer.hs+11−13
@@ -3,7 +3,7 @@
33module Reporting.Render.Type.Localizer
44 ( Localizer
55 , toDoc
6− , toString
6+ , toChars
77 , empty
88 , fromNames
99 , fromModule
@@ -18,10 +18,8 @@ import qualified Data.Name as Name
1818import qualified Data.Set as Set
1919
2020import qualified AST.Source as Src
21−import qualified AST.Valid as Valid
2221import qualified Elm.Compiler.Imports as Imports
2322import qualified Elm.ModuleName as ModuleName
24−import qualified Elm.Package as Pkg
2523import Reporting.Doc ((<>))
2624import qualified Reporting.Doc as D
2725import qualified Reporting.Annotation as A
@@ -58,27 +56,27 @@ empty =
5856
5957toDoc :: Localizer -> ModuleName.Canonical -> Name.Name -> D.Doc
6058toDoc localizer home name =
61− D.fromString (toString localizer home name)
59+ D.fromChars (toChars localizer home name)
6260
6361
64−toString :: Localizer -> ModuleName.Canonical -> Name.Name -> String
65−toString (Localizer localizer) moduleName@(ModuleName.Canonical _ home) name =
62+toChars :: Localizer -> ModuleName.Canonical -> Name.Name -> String
63+toChars (Localizer localizer) moduleName@(ModuleName.Canonical _ home) name =
6664 case Map.lookup home localizer of
6765 Nothing ->
68− Name.toString home <> "." <> Name.toString name
66+ Name.toChars home <> "." <> Name.toChars name
6967
7068 Just (Import alias exposing) ->
7169 case exposing of
7270 All ->
73− Name.toString name
71+ Name.toChars name
7472
7573 Only set ->
7674 if Set.member name set then
77− Name.toString name
75+ Name.toChars name
7876 else if name == Name.list && moduleName == ModuleName.list then
7977 "List"
8078 else
81− Name.toString (maybe home id alias) <> "." <> Name.toString name
79+ Name.toChars (maybe home id alias) <> "." <> Name.toChars name
8280
8381
8482
@@ -94,8 +92,8 @@ fromNames names =
9492-- FROM MODULE
9593
9694
97−fromModule :: Valid.Module -> Localizer
98−fromModule (Valid.Module name _ _ _ imports _ _ _ _ _) =
95+fromModule :: Src.Module -> Localizer
96+fromModule (Src.Module name _ imports _ _ _ _ _) =
9997 Localizer $ Map.fromList $
10098 (name, Import Nothing All) : map toPair imports
10199
@@ -133,7 +131,7 @@ replEmpty :: Localizer
133131replEmpty =
134132 Localizer $
135133 Map.insert Name.replModule (Import Nothing All) $
136− Map.fromList $ map toPair $ Imports.addDefaults Pkg.dummyName []
134+ Map.fromList $ map toPair $ Imports.addDefaults []
137135
138136
139137replAdd :: Name.Name -> Maybe Name.Name -> Src.Exposing -> Localizer -> Localizer
compiler/src/Reporting/Report.hs+5−5
@@ -8,8 +8,8 @@ module Reporting.Report
88 where
99
1010
11+import qualified Reporting.Annotation as A
1112import qualified Reporting.Doc as D
12−import qualified Reporting.Region as R
1313import qualified Reporting.Render.Code as Code
1414
1515
@@ -20,7 +20,7 @@ import qualified Reporting.Render.Code as Code
2020data Report =
2121 Report
2222 { _title :: String
23− , _region :: R.Region
23+ , _region :: A.Region
2424 , _sgstns :: [String]
2525 , _message :: D.Doc
2626 }
@@ -42,7 +42,7 @@ messageBar title filePath =
4242 usedSpace =
4343 4 + length title + 1 + length filePath
4444 in
45− D.dullcyan $ D.fromString $
45+ D.dullcyan $ D.fromChars $
4646 "-- " ++ title
4747 ++ " " ++ replicate (max 1 (80 - usedSpace)) '-'
4848 ++ " " ++ filePath
@@ -52,7 +52,7 @@ messageBar title filePath =
5252-- CODE FORMATTING
5353
5454
55−toCodeSnippet :: Code.Source -> R.Region -> Maybe R.Region -> (D.Doc, D.Doc) -> D.Doc
55+toCodeSnippet :: Code.Source -> A.Region -> Maybe A.Region -> (D.Doc, D.Doc) -> D.Doc
5656toCodeSnippet source region highlight (preHint, postHint) =
5757 D.vcat
5858 [ preHint
@@ -62,7 +62,7 @@ toCodeSnippet source region highlight (preHint, postHint) =
6262 ]
6363
6464
65−toCodePair :: Code.Source -> R.Region -> R.Region -> (D.Doc, D.Doc) -> (D.Doc, D.Doc, D.Doc) -> D.Doc
65+toCodePair :: Code.Source -> A.Region -> A.Region -> (D.Doc, D.Doc) -> (D.Doc, D.Doc, D.Doc) -> D.Doc
6666toCodePair source r1 r2 (oneStart, oneEnd) (twoStart, twoMiddle, twoEnd) =
6767 case Code.renderPair source r1 r2 of
6868 Code.OneLine codeDocs ->
compiler/src/Reporting/Warning.hs+10−10
@@ -13,8 +13,8 @@ import qualified Data.Name as Name
1313
1414import qualified AST.Canonical as Can
1515import qualified AST.Utils.Type as Type
16+import qualified Reporting.Annotation as A
1617import qualified Reporting.Doc as D
17−import qualified Reporting.Region as R
1818import qualified Reporting.Report as Report
1919import qualified Reporting.Render.Code as Code
2020import qualified Reporting.Render.Type as RT
@@ -26,9 +26,9 @@ import qualified Reporting.Render.Type.Localizer as L
2626
2727
2828data Warning
29− = UnusedImport R.Region Name.Name
30− | UnusedVariable R.Region Context Name.Name
31− | MissingTypeAnnotation R.Region Name.Name Can.Type
29+ = UnusedImport A.Region Name.Name
30+ | UnusedVariable A.Region Context Name.Name
31+ | MissingTypeAnnotation A.Region Name.Name Can.Type
3232
3333
3434data Context = Def | Pattern
@@ -46,7 +46,7 @@ toReport localizer source warning =
4646 Report.toCodeSnippet source region Nothing
4747 (
4848 D.reflow $
49− "Nothing from the `" <> Name.toString moduleName <> "` module is used in this file."
49+ "Nothing from the `" <> Name.toChars moduleName <> "` module is used in this file."
5050 ,
5151 "I recommend removing unused imports."
5252 )
@@ -57,18 +57,18 @@ toReport localizer source warning =
5757 Report.toCodeSnippet source region Nothing
5858 (
5959 D.reflow $
60− "You are not using `" <> Name.toString name <> "` anywhere."
60+ "You are not using `" <> Name.toChars name <> "` anywhere."
6161 ,
6262 D.stack
6363 [ D.reflow $
64− "Is there a typo? Maybe you intended to use `" <> Name.toString name
64+ "Is there a typo? Maybe you intended to use `" <> Name.toChars name
6565 <> "` somewhere but typed another name instead?"
6666 , D.reflow $
6767 defOrPat context
6868 ( "If you are sure there is no typo, remove the definition.\
6969 \ This way future readers will not have to wonder why it is there!"
7070 )
71− ( "If you are sure there is no typo, replace `" <> Name.toString name
71+ ( "If you are sure there is no typo, replace `" <> Name.toChars name
7272 <> "` with _ so future readers will not have to wonder why it is there!"
7373 )
7474 ]
@@ -81,10 +81,10 @@ toReport localizer source warning =
8181 D.reflow $
8282 case Type.deepDealias inferredType of
8383 Can.TLambda _ _ ->
84− "The `" <> Name.toString name <> "` function has no type annotation."
84+ "The `" <> Name.toChars name <> "` function has no type annotation."
8585
8686 _ ->
87− "The `" <> Name.toString name <> "` definition has no type annotation."
87+ "The `" <> Name.toChars name <> "` definition has no type annotation."
8888 ,
8989 D.stack
9090 [ "I inferred the type annotation myself though! You can copy it into your code:"
compiler/src/Type/Error.hs+3−3
@@ -282,7 +282,7 @@ toDiff localizer ctx tipe1 tipe2 =
282282
283283 -- start trying to find specific problems
284284
285− (Type home1 name1 args1, Type home2 name2 args2) | L.toString localizer home1 name1 == L.toString localizer home2 name2 ->
285+ (Type home1 name1 args1, Type home2 name2 args2) | L.toChars localizer home1 name1 == L.toChars localizer home2 name2 ->
286286 different
287287 (nameClashToDoc ctx localizer home1 name1 args1)
288288 (nameClashToDoc ctx localizer home2 name2 args2)
@@ -307,7 +307,7 @@ toDiff localizer ctx tipe1 tipe2 =
307307
308308 Nothing ->
309309 case t2 of
310− Type home2 name2 args2 | L.toString localizer home1 name1 == L.toString localizer home2 name2 ->
310+ Type home2 name2 args2 | L.toChars localizer home1 name1 == L.toChars localizer home2 name2 ->
311311 different
312312 (nameClashToDoc ctx localizer home1 name1 (map snd args1))
313313 (nameClashToDoc ctx localizer home2 name2 args2)
@@ -326,7 +326,7 @@ toDiff localizer ctx tipe1 tipe2 =
326326
327327 Nothing ->
328328 case t1 of
329− Type home1 name1 args1 | L.toString localizer home1 name1 == L.toString localizer home2 name2 ->
329+ Type home1 name1 args1 | L.toChars localizer home1 name1 == L.toChars localizer home2 name2 ->
330330 different
331331 (nameClashToDoc ctx localizer home1 name1 args1)
332332 (nameClashToDoc ctx localizer home2 name2 (map snd args2))