@@ -15,13 +15,13 @@ module Reporting.Error.Canonicalize
1515
1616import qualified Data.Char as Char
1717import qualified Data.Map as Map
18+import qualified Data.Name as Name
1819import qualified Data.Set as Set
1920
2021import qualified AST.Canonical as Can
2122import qualified AST.Source as Src
2223import qualified AST.Module.Name as ModuleName
2324import qualified Data.Index as Index
24−import qualified Elm.Name as N
2525import qualified Reporting.Annotation as A
2626import qualified Reporting.Doc as D
2727import Reporting.Doc (Doc, (<+>), (<>))
@@ -37,44 +37,44 @@ import qualified Reporting.Suggest as Suggest
3737
3838
3939data Error
40− = AnnotationTooShort R.Region N.Name Index.ZeroBased Int
41− | AmbiguousVar R.Region (Maybe N.Name) N.Name [ModuleName.Canonical]
42− | AmbiguousType R.Region (Maybe N.Name) N.Name [ModuleName.Canonical]
43− | AmbiguousCtor R.Region (Maybe N.Name) N.Name [ModuleName.Canonical]
44− | AmbiguousBinop R.Region N.Name [ModuleName.Canonical]
45− | BadArity R.Region BadArityContext N.Name Int Int
46− | Binop R.Region N.Name N.Name
47− | DuplicateDecl N.Name R.Region R.Region
48− | DuplicateType N.Name R.Region R.Region
49− | DuplicateCtor N.Name R.Region R.Region
50− | DuplicateBinop N.Name R.Region R.Region
51− | DuplicateField N.Name R.Region R.Region
52− | DuplicateAliasArg N.Name N.Name R.Region R.Region
53− | DuplicateUnionArg N.Name N.Name R.Region R.Region
54− | DuplicatePattern DuplicatePatternContext N.Name R.Region R.Region
55− | EffectNotFound R.Region N.Name
56− | EffectFunctionNotFound R.Region N.Name
57− | ExportDuplicate N.Name R.Region R.Region
58− | ExportNotFound R.Region VarKind N.Name [N.Name]
59− | ExportOpenAlias R.Region N.Name
60− | ImportCtorByName R.Region N.Name N.Name
61− | ImportNotFound R.Region N.Name [ModuleName.Canonical]
62− | ImportOpenAlias R.Region N.Name
63− | ImportExposingNotFound R.Region ModuleName.Canonical N.Name [N.Name]
64− | NotFoundVar R.Region (Maybe N.Name) N.Name PossibleNames
65− | NotFoundType R.Region (Maybe N.Name) N.Name PossibleNames
66− | NotFoundCtor R.Region (Maybe N.Name) N.Name PossibleNames
67− | NotFoundBinop R.Region N.Name (Set.Set N.Name)
68− | PatternHasRecordCtor R.Region N.Name
69− | PortPayloadInvalid R.Region N.Name Can.Type InvalidPayload
70− | PortTypeInvalid R.Region N.Name PortProblem
71− | RecursiveAlias R.Region N.Name [N.Name] Src.Type [N.Name]
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]
7272 | RecursiveDecl [Can.Def]
73− | RecursiveLet (A.Located N.Name) [N.Name]
74− | Shadowing N.Name R.Region R.Region
73+ | RecursiveLet (A.Located Name.Name) [Name.Name]
74+ | Shadowing Name.Name R.Region R.Region
7575 | TupleLargerThanThree R.Region
76− | TypeVarsUnboundInUnion R.Region N.Name [N.Name] (N.Name, R.Region) [(N.Name, R.Region)]
77− | TypeVarsMessedUpInAlias R.Region N.Name [N.Name] [(N.Name, R.Region)] [(N.Name, 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)]
7878
7979
8080data BadArityContext
@@ -84,7 +84,7 @@ data BadArityContext
8484
8585data DuplicatePatternContext
8686 = DPLambdaArgs
87− | DPFuncArgs N.Name
87+ | DPFuncArgs Name.Name
8888 | DPCaseBranch
8989 | DPLetBinding
9090 | DPDestruct
@@ -93,8 +93,8 @@ data DuplicatePatternContext
9393data InvalidPayload
9494 = ExtendedRecord
9595 | Function
96− | TypeVariable N.Name
97− | UnsupportedType N.Name
96+ | TypeVariable Name.Name
97+ | UnsupportedType Name.Name
9898
9999
100100data PortProblem
@@ -107,8 +107,8 @@ data PortProblem
107107
108108data PossibleNames =
109109 PossibleNames
110− { _locals :: Set.Set N.Name
111− , _quals :: Map.Map N.Name (Set.Set N.Name)
110+ { _locals :: Set.Set Name.Name
111+ , _quals :: Map.Map Name.Name (Set.Set Name.Name)
112112 }
113113
114114
@@ -123,7 +123,7 @@ data VarKind
123123 | BadType
124124
125125
126−toKindInfo :: VarKind -> N.Name -> ( Doc, Doc, Doc )
126+toKindInfo :: VarKind -> Name.Name -> ( Doc, Doc, Doc )
127127toKindInfo kind name =
128128 case kind of
129129 BadOp ->
@@ -155,7 +155,7 @@ toReport source err =
155155 Report.toCodeSnippet source region Nothing
156156 (
157157 D.reflow $
158− "The type annotation for `" <> N.toString name <> "` says it can accept "
158+ "The type annotation for `" <> Name.toString name <> "` says it can accept "
159159 <> D.args numTypeArgs <> ", but the definition says it has "
160160 <> D.args numDefArgs <> ":"
161161 ,
@@ -189,7 +189,7 @@ toReport source err =
189189 Report.toCodeSnippet source region Nothing
190190 (
191191 D.reflow $
192− "The `" <> N.toString name <> "` " <> thing <> " needs "
192+ "The `" <> Name.toString name <> "` " <> thing <> " needs "
193193 <> D.args expected <> ", but I see " <> show actual <> " instead:"
194194 ,
195195 D.reflow $
@@ -201,7 +201,7 @@ toReport source err =
201201 Report.toCodeSnippet source region Nothing
202202 (
203203 D.reflow $
204− "The `" <> N.toString name <> "` " <> thing <> " needs "
204+ "The `" <> Name.toString name <> "` " <> thing <> " needs "
205205 <> D.args expected <> ", but I see " <> show actual <> " instead:"
206206 ,
207207 if actual - expected == 1 then
@@ -215,7 +215,7 @@ toReport source err =
215215 Report.toCodeSnippet source region Nothing
216216 (
217217 D.reflow $
218− "You cannot mix (" <> N.toString op1 <> ") and (" <> N.toString op2 <> ") without parentheses."
218+ "You cannot mix (" <> Name.toString op1 <> ") and (" <> Name.toString op2 <> ") without parentheses."
219219 ,
220220 D.reflow
221221 "I do not know how to group these expressions. Add parentheses for me!"
@@ -223,59 +223,59 @@ toReport source err =
223223
224224 DuplicateDecl name r1 r2 ->
225225 nameClash source r1 r2 $
226− "This file has multiple `" <> N.toString name <> "` declarations."
226+ "This file has multiple `" <> Name.toString name <> "` declarations."
227227
228228 DuplicateType name r1 r2 ->
229229 nameClash source r1 r2 $
230− "This file defines multiple `" <> N.toString name <> "` types."
230+ "This file defines multiple `" <> Name.toString name <> "` types."
231231
232232 DuplicateCtor name r1 r2 ->
233233 nameClash source r1 r2 $
234− "This file defines multiple `" <> N.toString name <> "` type constructors."
234+ "This file defines multiple `" <> Name.toString name <> "` type constructors."
235235
236236 DuplicateBinop name r1 r2 ->
237237 nameClash source r1 r2 $
238− "This file defines multiple (" <> N.toString name <> ") operators."
238+ "This file defines multiple (" <> Name.toString name <> ") operators."
239239
240240 DuplicateField name r1 r2 ->
241241 nameClash source r1 r2 $
242− "This record has multiple `" <> N.toString name <> "` fields."
242+ "This record has multiple `" <> Name.toString name <> "` fields."
243243
244244 DuplicateAliasArg typeName name r1 r2 ->
245245 nameClash source r1 r2 $
246− "The `" <> N.toString typeName <> "` type alias has multilpe `" <> N.toString name <> "` type variables."
246+ "The `" <> Name.toString typeName <> "` type alias has multilpe `" <> Name.toString name <> "` type variables."
247247
248248 DuplicateUnionArg typeName name r1 r2 ->
249249 nameClash source r1 r2 $
250− "The `" <> N.toString typeName <> "` type has multilpe `" <> N.toString name <> "` type variables."
250+ "The `" <> Name.toString typeName <> "` type has multilpe `" <> Name.toString name <> "` type variables."
251251
252252 DuplicatePattern context name r1 r2 ->
253253 nameClash source r1 r2 $
254254 case context of
255255 DPLambdaArgs ->
256− "This anonymous function has multiple `" <> N.toString name <> "` arguments."
256+ "This anonymous function has multiple `" <> Name.toString name <> "` arguments."
257257
258258 DPFuncArgs funcName ->
259− "The `" <> N.toString funcName <> "` function has multiple `" <> N.toString name <> "` arguments."
259+ "The `" <> Name.toString funcName <> "` function has multiple `" <> Name.toString name <> "` arguments."
260260
261261 DPCaseBranch ->
262− "This `case` pattern has multiple `" <> N.toString name <> "` variables."
262+ "This `case` pattern has multiple `" <> Name.toString name <> "` variables."
263263
264264 DPLetBinding ->
265− "This `let` expression defines `" <> N.toString name <> "` more than once!"
265+ "This `let` expression defines `" <> Name.toString name <> "` more than once!"
266266
267267 DPDestruct ->
268− "This pattern contains multiple `" <> N.toString name <> "` variables."
268+ "This pattern contains multiple `" <> Name.toString name <> "` variables."
269269
270270 EffectNotFound region name ->
271271 Report.Report "EFFECT PROBLEM" region [] $
272272 Report.toCodeSnippet source region Nothing
273273 (
274274 D.reflow $
275− "You have declared that `" ++ N.toString name ++ "` is an effect type:"
275+ "You have declared that `" ++ Name.toString name ++ "` is an effect type:"
276276 ,
277277 D.reflow $
278− "But I cannot find a union type named `" ++ N.toString name ++ "` in this file!"
278+ "But I cannot find a union type named `" ++ Name.toString name ++ "` in this file!"
279279 )
280280
281281 EffectFunctionNotFound region name ->
@@ -283,17 +283,17 @@ toReport source err =
283283 Report.toCodeSnippet source region Nothing
284284 (
285285 D.reflow $
286− "This kind of effect module must define a `" ++ N.toString name ++ "` function."
286+ "This kind of effect module must define a `" ++ Name.toString name ++ "` function."
287287 ,
288288 D.reflow $
289− "But I cannot find `" ++ N.toString name ++ "` in this file!"
289+ "But I cannot find `" ++ Name.toString name ++ "` in this file!"
290290 )
291291
292292
293293 ExportDuplicate name r1 r2 ->
294294 let
295295 messageThatEndsWithPunctuation =
296− "You are trying to expose `" <> N.toString name <> "` multiple times!"
296+ "You are trying to expose `" <> Name.toString name <> "` multiple times!"
297297 in
298298 Report.Report "REDUNDANT EXPORT" r2 [] $
299299 Report.toCodePair source r1 r2
@@ -313,8 +313,8 @@ toReport source err =
313313 ExportNotFound region kind rawName possibleNames ->
314314 let
315315 suggestions =
316− map N.toString $ take 4 $
317− Suggest.sort (N.toString rawName) N.toString possibleNames
316+ map Name.toString $ take 4 $
317+ Suggest.sort (Name.toString rawName) Name.toString possibleNames
318318 in
319319 Report.Report "UNKNOWN EXPORT" region suggestions $
320320 let (a, thing, name) = toKindInfo kind rawName in
@@ -344,7 +344,7 @@ toReport source err =
344344 (
345345 D.reflow $
346346 "The (..) syntax is for exposing union type constructors. It cannot be used with a type alias like `"
347− ++ N.toString name ++ "` though."
347+ ++ Name.toString name ++ "` though."
348348 ,
349349 D.reflow $
350350 "Remove the (..) and you should be fine!"
@@ -355,7 +355,7 @@ toReport source err =
355355 Report.toCodeSnippet source region Nothing
356356 (
357357 D.reflow $
358− "You are trying to import the `" <> N.toString ctor
358+ "You are trying to import the `" <> Name.toString ctor
359359 <> "` type constructor by name:"
360360 ,
361361 D.fillSep
@@ -375,7 +375,7 @@ toReport source err =
375375 Report.toCodeSnippet source region Nothing
376376 (
377377 D.reflow $
378− "I could not find a `" <> N.toString name <> "` module to import!"
378+ "I could not find a `" <> Name.toString name <> "` module to import!"
379379 ,
380380 mempty
381381 )
@@ -385,7 +385,7 @@ toReport source err =
385385 Report.toCodeSnippet source region Nothing
386386 (
387387 D.reflow $
388− "The `" <> N.toString name <> "` type alias cannot be followed by (..) like this:"
388+ "The `" <> Name.toString name <> "` type alias cannot be followed by (..) like this:"
389389 ,
390390 D.stack
391391 [ "Remove the (..) and it should work."
@@ -399,16 +399,16 @@ toReport source err =
399399 ImportExposingNotFound region (ModuleName.Canonical _ home) value possibleNames ->
400400 let
401401 suggestions =
402− map N.toString $ take 4 $
403− Suggest.sort (N.toString home) N.toString possibleNames
402+ map Name.toString $ take 4 $
403+ Suggest.sort (Name.toString home) Name.toString possibleNames
404404 in
405405 Report.Report "BAD IMPORT" region suggestions $
406406 Report.toCodeSnippet source region Nothing
407407 (
408408 D.reflow $
409− "The `" <> N.toString home
409+ "The `" <> Name.toString home
410410 <> "` module does not expose `"
411− <> N.toString value <> "`:"
411+ <> Name.toString value <> "`:"
412412 ,
413413 case map D.fromString suggestions of
414414 [] ->
@@ -454,7 +454,7 @@ toReport source err =
454454 [ D.reflow "Switch to (/=) instead."
455455 , D.toSimpleNote $
456456 "Our (/=) operator is supposed to look like a real “not equal” sign (≠). I hope that history will remember ("
457− ++ N.toString op ++ ") as a weird and temporary choice."
457+ ++ Name.toString op ++ ") as a weird and temporary choice."
458458 ]
459459 )
460460
@@ -491,8 +491,8 @@ toReport source err =
491491 else
492492 let
493493 suggestions =
494− map N.toString $ take 2 $
495− Suggest.sort (N.toString op) N.toString (Set.toList locals)
494+ map Name.toString $ take 2 $
495+ Suggest.sort (Name.toString op) Name.toString (Set.toList locals)
496496
497497 format altOp =
498498 D.green $ "(" <> altOp <> ")"
@@ -501,7 +501,7 @@ toReport source err =
501501 Report.toCodeSnippet source region Nothing
502502 (
503503 D.reflow $
504− "I do not recognize the (" ++ N.toString op ++ ") operator."
504+ "I do not recognize the (" ++ Name.toString op ++ ") operator."
505505 ,
506506 D.fillSep $
507507 ["Is","there","an","`import`","and","`exposing`","entry","for","it?"]
@@ -519,7 +519,7 @@ toReport source err =
519519 Report.toCodeSnippet source region Nothing
520520 (
521521 D.reflow $
522− "You can construct records by using `" <> N.toString name
522+ "You can construct records by using `" <> Name.toString name
523523 <> "` as a function, but it is not available in pattern matching like this:"
524524 ,
525525 D.reflow $
@@ -533,7 +533,7 @@ toReport source err =
533533 Report.toCodeSnippet source region Nothing
534534 (
535535 D.reflow $
536− "The `" <> N.toString portName <> "` port is trying to transmit " <> aBadKindOfThing <> ":"
536+ "The `" <> Name.toString portName <> "` port is trying to transmit " <> aBadKindOfThing <> ":"
537537 ,
538538 D.stack
539539 [ elaboration
@@ -570,14 +570,14 @@ toReport source err =
570570 "an unspecified type"
571571 ,
572572 D.reflow $
573− "But type variables like `" <> N.toString name <> "` cannot flow through ports.\
573+ "But type variables like `" <> Name.toString name <> "` cannot flow through ports.\
574574 \ I need to know exactly what type of data I am getting, so I can guarantee that\
575575 \ unexpected data cannot sneak in and crash the Elm program."
576576 )
577577
578578 UnsupportedType name ->
579579 (
580− "a `" <> N.toString name <> "` value"
580+ "a `" <> Name.toString name <> "` value"
581581 ,
582582 D.stack
583583 [ D.reflow $ "I cannot handle that. The types that CAN flow in and out of Elm include:"
@@ -611,7 +611,7 @@ toReport source err =
611611 case portProblem of
612612 CmdNoArg ->
613613 (
614− "The `" <> N.toString name <> "` port cannot be just a command."
614+ "The `" <> Name.toString name <> "` port cannot be just a command."
615615 ,
616616 D.reflow $
617617 "It can be (() -> Cmd msg) if you just need to trigger a JavaScript\
@@ -620,7 +620,7 @@ toReport source err =
620620
621621 CmdExtraArgs n ->
622622 (
623− "The `" <> N.toString name <> "` port can only send ONE value out to JavaScript."
623+ "The `" <> Name.toString name <> "` port can only send ONE value out to JavaScript."
624624 ,
625625 let
626626 theseItemsInSomething
@@ -634,7 +634,7 @@ toReport source err =
634634
635635 CmdBadMsg ->
636636 (
637− "The `" <> N.toString name <> "` port cannot send any messages to the `update` function."
637+ "The `" <> Name.toString name <> "` port cannot send any messages to the `update` function."
638638 ,
639639 D.reflow $
640640 "It must produce a (Cmd msg) type. Notice the lower case `msg` type\
@@ -643,13 +643,13 @@ toReport source err =
643643 )
644644
645645 SubBad ->
646− ( "There is something off about this `" <> N.toString name <> "` port declaration."
646+ ( "There is something off about this `" <> Name.toString name <> "` port declaration."
647647 ,
648648 D.stack
649649 [ D.reflow $
650650 "To receive messages from JavaScript, you need to define a port like this:"
651651 , D.indent 4 $ D.dullyellow $ D.fromString $
652− "port " <> N.toString name <> " : (Int -> msg) -> Sub msg"
652+ "port " <> Name.toString name <> " : (Int -> msg) -> Sub msg"
653653 , D.reflow $
654654 "Now every time JS sends an `Int` to this port, it is converted to a `msg`.\
655655 \ And if you subscribe, those `msg` values will be piped into your `update`\
@@ -659,7 +659,7 @@ toReport source err =
659659
660660 NotCmdOrSub ->
661661 (
662− "I am confused about the `" <> N.toString name <> "` port declaration."
662+ "I am confused about the `" <> Name.toString name <> "` port declaration."
663663 ,
664664 D.reflow $
665665 "Ports need to produce a command (Cmd) or a subscription (Sub) but\
@@ -693,16 +693,16 @@ toReport source err =
693693 [] ->
694694 (
695695 D.reflow $
696− "The `" <> N.toString name <> "` value is defined directly in terms of itself, causing an infinite loop."
696+ "The `" <> Name.toString name <> "` value is defined directly in terms of itself, causing an infinite loop."
697697 ,
698698 D.stack
699699 [ makeTheory "Are you are trying to mutate a variable?" $
700− "Elm does not have mutation, so when I see " ++ N.toString name
701− ++ " defined in terms of " ++ N.toString name
700+ "Elm does not have mutation, so when I see " ++ Name.toString name
701+ ++ " defined in terms of " ++ Name.toString name
702702 ++ ", I treat it as a recursive definition. Try giving the new value a new name!"
703703 , makeTheory "Maybe you DO want a recursive value?" $
704− "To define " ++ N.toString name ++ " we need to know what " ++ N.toString name
705− ++ " is, so let’s expand it. Wait, but now we need to know what " ++ N.toString name
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
706706 ++ " is, so let’s expand it... This will keep going infinitely!"
707707 , D.link "Hint"
708708 "The root problem is often a typo in some variable name, but I recommend reading"
@@ -714,11 +714,11 @@ toReport source err =
714714 names ->
715715 (
716716 D.reflow $
717− "The `" <> N.toString name <> "` definition is causing a very tricky infinite loop."
717+ "The `" <> Name.toString name <> "` definition is causing a very tricky infinite loop."
718718 ,
719719 D.stack
720720 [ D.reflow $
721− "The `" <> N.toString name
721+ "The `" <> Name.toString name
722722 <> "` value depends on itself through the following chain of definitions:"
723723 , D.cycle 4 (name:names)
724724 , D.link "Hint"
@@ -739,16 +739,16 @@ toReport source err =
739739 in
740740 (
741741 D.reflow $
742− "The `" <> N.toString name <> "` value is defined directly in terms of itself, causing an infinite loop."
742+ "The `" <> Name.toString name <> "` value is defined directly in terms of itself, causing an infinite loop."
743743 ,
744744 D.stack
745745 [ makeTheory "Are you are trying to mutate a variable?" $
746− "Elm does not have mutation, so when I see " ++ N.toString name
747− ++ " defined in terms of " ++ N.toString name
746+ "Elm does not have mutation, so when I see " ++ Name.toString name
747+ ++ " defined in terms of " ++ Name.toString name
748748 ++ ", I treat it as a recursive definition. Try giving the new value a new name!"
749749 , makeTheory "Maybe you DO want a recursive value?" $
750− "To define " ++ N.toString name ++ " we need to know what " ++ N.toString name
751− ++ " is, so let’s expand it. Wait, but now we need to know what " ++ N.toString name
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
752752 ++ " is, so let’s expand it... This will keep going infinitely!"
753753 , D.link "Hint"
754754 "The root problem is often a typo in some variable name, but I recommend reading"
@@ -764,7 +764,7 @@ toReport source err =
764764 ,
765765 D.stack
766766 [ D.reflow $
767− "The `" <> N.toString name
767+ "The `" <> Name.toString name
768768 <> "` value depends on itself through the following chain of definitions:"
769769 , D.cycle 4 (name:names)
770770 , D.link "Hint"
@@ -780,7 +780,7 @@ toReport source err =
780780 ( "These variables cannot have the same name:"
781781 , advice
782782 )
783− ( D.reflow $ "The name `" <> N.toString name <> "` is first defined here:"
783+ ( D.reflow $ "The name `" <> Name.toString name <> "` is first defined here:"
784784 , "But then it is defined AGAIN over here:"
785785 , advice
786786 )
@@ -902,7 +902,7 @@ toReport source err =
902902 Report.toCodeSnippet source aliasRegion Nothing
903903 (
904904 D.reflow $
905− "Type alias `" <> N.toString typeName <> "` has some type variable problems."
905+ "Type alias `" <> Name.toString typeName <> "` has some type variable problems."
906906 ,
907907 D.stack
908908 [ D.fillSep $ theseAreUsed ++ butTheseAreUnused
@@ -921,7 +921,7 @@ toReport source err =
921921-- BAD TYPE VARIABLES
922922
923923
924−unboundTypeVars :: Code.Source -> R.Region -> [D.Doc] -> N.Name -> [N.Name] -> (N.Name, R.Region) -> [(N.Name, R.Region)] -> Report.Report
924+unboundTypeVars :: Code.Source -> R.Region -> [D.Doc] -> Name.Name -> [Name.Name] -> (Name.Name, R.Region) -> [(Name.Name, R.Region)] -> Report.Report
925925unboundTypeVars source declRegion tipe typeName allVars (unboundVar, varRegion) unboundVars =
926926 let
927927 backQuote name =
@@ -960,7 +960,7 @@ unboundTypeVars source declRegion tipe typeName allVars (unboundVar, varRegion)
960960 ++ map (D.green . D.fromName) (unboundVar : map fst unboundVars)
961961 ++ ["=", "..."]
962962 , D.reflow $
963− "Why? Well, imagine one `" ++ N.toString typeName ++ "` where `" ++ N.toString unboundVar ++
963+ "Why? Well, imagine one `" ++ Name.toString typeName ++ "` where `" ++ Name.toString unboundVar ++
964964 "` is an Int and another where it is a Bool. When we explicitly list the type\
965965 \ variables, the type checker can see that they are actually different types."
966966 ]
@@ -993,7 +993,7 @@ nameClash source r1 r2 messageThatEndsWithPunctuation =
993993-- AMBIGUOUS NAME
994994
995995
996−ambiguousName :: Code.Source -> R.Region -> Maybe N.Name -> N.Name -> [ModuleName.Canonical] -> String -> Report.Report
996+ambiguousName :: Code.Source -> R.Region -> Maybe Name.Name -> Name.Name -> [ModuleName.Canonical] -> String -> Report.Report
997997ambiguousName source region maybePrefix name possibleHomes thing =
998998 Report.Report "AMBIGUOUS NAME" region [] $
999999 Report.toCodeSnippet source region Nothing $
@@ -1007,12 +1007,12 @@ ambiguousName source region maybePrefix name possibleHomes thing =
10071007 if length possibleHomes == 2 then "both" else "all"
10081008 in
10091009 (
1010− D.reflow $ "This usage of `" ++ N.toString name ++ "` is ambiguous."
1010+ D.reflow $ "This usage of `" ++ Name.toString name ++ "` is ambiguous."
10111011 ,
10121012 D.stack
10131013 [ D.reflow $
10141014 "Check your imports. The following modules " ++ bothOrAll
1015− ++ " expose a `" ++ N.toString name ++ "` " ++ thing ++ ":"
1015+ ++ " expose a `" ++ Name.toString name ++ "` " ++ thing ++ ":"
10161016 , D.indent 4 $ D.vcat $ map homeToYellowDoc possibleHomes
10171017 , D.reflowLink "Read" "imports" "to learn how to clarify which one you want."
10181018 ]
@@ -1046,18 +1046,18 @@ ambiguousName source region maybePrefix name possibleHomes thing =
10461046-- NOT FOUND
10471047
10481048
1049−notFound :: Code.Source -> R.Region -> Maybe N.Name -> N.Name -> String -> PossibleNames -> Report.Report
1049+notFound :: Code.Source -> R.Region -> Maybe Name.Name -> Name.Name -> String -> PossibleNames -> Report.Report
10501050notFound source region maybePrefix name thing (PossibleNames locals quals) =
10511051 let
10521052 givenName =
1053− maybe N.toString toQualString maybePrefix name
1053+ maybe Name.toString toQualString maybePrefix name
10541054
10551055 possibleNames =
10561056 let
10571057 addQuals prefix localSet allNames =
10581058 Set.foldr (\x xs -> toQualString prefix x : xs) allNames localSet
10591059 in
1060− Map.foldrWithKey addQuals (map N.toString (Set.toList locals)) quals
1060+ Map.foldrWithKey addQuals (map Name.toString (Set.toList locals)) quals
10611061
10621062 nearbyNames =
10631063 take 4 (Suggest.sort givenName id possibleNames)
@@ -1094,19 +1094,19 @@ notFound source region maybePrefix name thing (PossibleNames locals quals) =
10941094 case Map.lookup prefix quals of
10951095 Nothing ->
10961096 toDetails
1097− ("I cannot find a `" ++ N.toString prefix ++ "` module. Is there an `import` for it?")
1098− ("I cannot find a `" ++ N.toString prefix ++ "` import. These names seem close though:")
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:")
10991099
11001100 Just _ ->
11011101 toDetails
1102− ("The `" ++ N.toString prefix ++ "` module does not expose a `" ++ N.toString name ++ "` " ++ thing ++ ".")
1103− ("The `" ++ N.toString prefix ++ "` module does not expose a `" ++ N.toString name ++ "` " ++ thing ++ ". These names seem close though:")
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:")
11041104 )
11051105
11061106
1107−toQualString :: N.Name -> N.Name -> String
1107+toQualString :: Name.Name -> Name.Name -> String
11081108toQualString prefix name =
1109− N.toString prefix ++ "." ++ N.toString name
1109+ Name.toString prefix ++ "." ++ Name.toString name
11101110
11111111
11121112
@@ -1200,7 +1200,7 @@ modHint =
12001200-- ARG MISMATCH
12011201
12021202
1203−_argMismatchReport :: Code.Source -> R.Region -> String -> N.Name -> Int -> Int -> Report.Report
1203+_argMismatchReport :: Code.Source -> R.Region -> String -> Name.Name -> Int -> Int -> Report.Report
12041204_argMismatchReport source region kind name expected actual =
12051205 let
12061206 numArgs =
@@ -1212,7 +1212,7 @@ _argMismatchReport source region kind name expected actual =
12121212 Report.toCodeSnippet source region Nothing
12131213 (
12141214 D.reflow $
1215− kind <> " " <> N.toString name <> " has " <> numArgs <> "."
1215+ kind <> " " <> Name.toString name <> " has " <> numArgs <> "."
12161216 ,
12171217 D.reflow $
12181218 "Expecting " <> show expected <> ", but got " <> show actual <> "."
@@ -1223,7 +1223,7 @@ _argMismatchReport source region kind name expected actual =
12231223-- BAD ALIAS RECURSION
12241224
12251225
1226−aliasRecursionReport :: Code.Source -> R.Region -> N.Name -> [N.Name] -> Src.Type -> [N.Name] -> Report.Report
1226+aliasRecursionReport :: Code.Source -> R.Region -> Name.Name -> [Name.Name] -> Src.Type -> [Name.Name] -> Report.Report
12271227aliasRecursionReport source region name args tipe others =
12281228 case others of
12291229 [] ->
@@ -1262,7 +1262,7 @@ aliasRecursionReport source region name args tipe others =
12621262 )
12631263
12641264
1265−aliasToUnionDoc :: N.Name -> [N.Name] -> Src.Type -> Doc
1265+aliasToUnionDoc :: Name.Name -> [Name.Name] -> Src.Type -> Doc
12661266aliasToUnionDoc name args tipe =
12671267 D.vcat
12681268 [ D.dullyellow $