@@ -15,13 +15,13 @@ module Reporting.Error.Canonicalize
16import qualified Data.Char as Char
16import qualified Data.Char as Char
17import qualified Data.Map as Map
17import qualified Data.Map as Map
18+import qualified Data.Name as Name
18import qualified Data.Set as Set
19import qualified Data.Set as Set
20import qualified AST.Canonical as Can
21import qualified AST.Canonical as Can
21import qualified AST.Source as Src
22import qualified AST.Source as Src
22import qualified AST.Module.Name as ModuleName
23import qualified AST.Module.Name as ModuleName
23import qualified Data.Index as Index
24import qualified Data.Index as Index
24−import qualified Elm.Name as N
25import qualified Reporting.Annotation as A
25import qualified Reporting.Annotation as A
26import qualified Reporting.Doc as D
26import qualified Reporting.Doc as D
27import Reporting.Doc (Doc, (<+>), (<>))
27import Reporting.Doc (Doc, (<+>), (<>))
@@ -37,44 +37,44 @@ import qualified Reporting.Suggest as Suggest
40− = AnnotationTooShort R.Region N.Name Index.ZeroBased Int
40+ = AnnotationTooShort R.Region Name.Name Index.ZeroBased Int
41− | AmbiguousVar R.Region (Maybe N.Name) N.Name [ModuleName.Canonical]
41+ | AmbiguousVar R.Region (Maybe Name.Name) Name.Name [ModuleName.Canonical]
42− | AmbiguousType R.Region (Maybe N.Name) N.Name [ModuleName.Canonical]
42+ | AmbiguousType R.Region (Maybe Name.Name) Name.Name [ModuleName.Canonical]
43− | AmbiguousCtor R.Region (Maybe N.Name) N.Name [ModuleName.Canonical]
43+ | AmbiguousCtor R.Region (Maybe Name.Name) Name.Name [ModuleName.Canonical]
44− | AmbiguousBinop R.Region N.Name [ModuleName.Canonical]
44+ | AmbiguousBinop R.Region Name.Name [ModuleName.Canonical]
45− | BadArity R.Region BadArityContext N.Name Int Int
45+ | BadArity R.Region BadArityContext Name.Name Int Int
46− | Binop R.Region N.Name N.Name
46+ | Binop R.Region Name.Name Name.Name
47− | DuplicateDecl N.Name R.Region R.Region
47+ | DuplicateDecl Name.Name R.Region R.Region
48− | DuplicateType N.Name R.Region R.Region
48+ | DuplicateType Name.Name R.Region R.Region
49− | DuplicateCtor N.Name R.Region R.Region
49+ | DuplicateCtor Name.Name R.Region R.Region
50− | DuplicateBinop N.Name R.Region R.Region
50+ | DuplicateBinop Name.Name R.Region R.Region
51− | DuplicateField N.Name R.Region R.Region
51+ | DuplicateField Name.Name R.Region R.Region
52− | DuplicateAliasArg N.Name N.Name R.Region R.Region
52+ | DuplicateAliasArg Name.Name Name.Name R.Region R.Region
53− | DuplicateUnionArg N.Name N.Name R.Region R.Region
53+ | DuplicateUnionArg Name.Name Name.Name R.Region R.Region
54− | DuplicatePattern DuplicatePatternContext N.Name R.Region R.Region
54+ | DuplicatePattern DuplicatePatternContext Name.Name R.Region R.Region
55− | EffectNotFound R.Region N.Name
55+ | EffectNotFound R.Region Name.Name
56− | EffectFunctionNotFound R.Region N.Name
56+ | EffectFunctionNotFound R.Region Name.Name
57− | ExportDuplicate N.Name R.Region R.Region
57+ | ExportDuplicate Name.Name R.Region R.Region
58− | ExportNotFound R.Region VarKind N.Name [N.Name]
58+ | ExportNotFound R.Region VarKind Name.Name [Name.Name]
59− | ExportOpenAlias R.Region N.Name
59+ | ExportOpenAlias R.Region Name.Name
60− | ImportCtorByName R.Region N.Name N.Name
60+ | ImportCtorByName R.Region Name.Name Name.Name
61− | ImportNotFound R.Region N.Name [ModuleName.Canonical]
61+ | ImportNotFound R.Region Name.Name [ModuleName.Canonical]
62− | ImportOpenAlias R.Region N.Name
62+ | ImportOpenAlias R.Region Name.Name
63− | ImportExposingNotFound R.Region ModuleName.Canonical N.Name [N.Name]
63+ | ImportExposingNotFound R.Region ModuleName.Canonical Name.Name [Name.Name]
64− | NotFoundVar R.Region (Maybe N.Name) N.Name PossibleNames
64+ | NotFoundVar R.Region (Maybe Name.Name) Name.Name PossibleNames
65− | NotFoundType R.Region (Maybe N.Name) N.Name PossibleNames
65+ | NotFoundType R.Region (Maybe Name.Name) Name.Name PossibleNames
66− | NotFoundCtor R.Region (Maybe N.Name) N.Name PossibleNames
66+ | NotFoundCtor R.Region (Maybe Name.Name) Name.Name PossibleNames
67− | NotFoundBinop R.Region N.Name (Set.Set N.Name)
67+ | NotFoundBinop R.Region Name.Name (Set.Set Name.Name)
68− | PatternHasRecordCtor R.Region N.Name
68+ | PatternHasRecordCtor R.Region Name.Name
69− | PortPayloadInvalid R.Region N.Name Can.Type InvalidPayload
69+ | PortPayloadInvalid R.Region Name.Name Can.Type InvalidPayload
70− | PortTypeInvalid R.Region N.Name PortProblem
70+ | PortTypeInvalid R.Region Name.Name PortProblem
71− | RecursiveAlias R.Region N.Name [N.Name] Src.Type [N.Name]
71+ | RecursiveAlias R.Region Name.Name [Name.Name] Src.Type [Name.Name]
72 | RecursiveDecl [Can.Def]
72 | RecursiveDecl [Can.Def]
73− | RecursiveLet (A.Located N.Name) [N.Name]
73+ | RecursiveLet (A.Located Name.Name) [Name.Name]
74− | Shadowing N.Name R.Region R.Region
74+ | Shadowing Name.Name R.Region R.Region
75 | TupleLargerThanThree R.Region
75 | TupleLargerThanThree R.Region
76− | TypeVarsUnboundInUnion 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 N.Name [N.Name] [(N.Name, R.Region)] [(N.Name, R.Region)]
77+ | TypeVarsMessedUpInAlias R.Region Name.Name [Name.Name] [(Name.Name, R.Region)] [(Name.Name, R.Region)]
80data BadArityContext
80data BadArityContext
@@ -84,7 +84,7 @@ data BadArityContext
85data DuplicatePatternContext
85data DuplicatePatternContext
86 = DPLambdaArgs
86 = DPLambdaArgs
87− | DPFuncArgs N.Name
87+ | DPFuncArgs Name.Name
88 | DPCaseBranch
88 | DPCaseBranch
89 | DPLetBinding
89 | DPLetBinding
90 | DPDestruct
90 | DPDestruct
@@ -93,8 +93,8 @@ data DuplicatePatternContext
93data InvalidPayload
93data InvalidPayload
94 = ExtendedRecord
94 = ExtendedRecord
95 | Function
95 | Function
96− | TypeVariable N.Name
96+ | TypeVariable Name.Name
97− | UnsupportedType N.Name
97+ | UnsupportedType Name.Name
100data PortProblem
100data PortProblem
@@ -107,8 +107,8 @@ data PortProblem
108data PossibleNames =
108data PossibleNames =
109 PossibleNames
109 PossibleNames
110− { _locals :: Set.Set N.Name
110+ { _locals :: Set.Set Name.Name
111− , _quals :: Map.Map N.Name (Set.Set N.Name)
111+ , _quals :: Map.Map Name.Name (Set.Set Name.Name)
@@ -123,7 +123,7 @@ data VarKind
123 | BadType
123 | BadType
126−toKindInfo :: VarKind -> N.Name -> ( Doc, Doc, Doc )
126+toKindInfo :: VarKind -> Name.Name -> ( Doc, Doc, Doc )
127toKindInfo kind name =
127toKindInfo kind name =
128 case kind of
128 case kind of
@@ -155,7 +155,7 @@ toReport source err =
155 Report.toCodeSnippet source region Nothing
155 Report.toCodeSnippet source region Nothing
157 D.reflow $
157 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 "
159 <> D.args numTypeArgs <> ", but the definition says it has "
159 <> D.args numTypeArgs <> ", but the definition says it has "
160 <> D.args numDefArgs <> ":"
160 <> D.args numDefArgs <> ":"
@@ -189,7 +189,7 @@ toReport source err =
189 Report.toCodeSnippet source region Nothing
189 Report.toCodeSnippet source region Nothing
191 D.reflow $
191 D.reflow $
192− "The `" <> N.toString name <> "` " <> thing <> " needs "
192+ "The `" <> Name.toString name <> "` " <> thing <> " needs "
193 <> D.args expected <> ", but I see " <> show actual <> " instead:"
193 <> D.args expected <> ", but I see " <> show actual <> " instead:"
195 D.reflow $
195 D.reflow $
@@ -201,7 +201,7 @@ toReport source err =
201 Report.toCodeSnippet source region Nothing
201 Report.toCodeSnippet source region Nothing
203 D.reflow $
203 D.reflow $
204− "The `" <> N.toString name <> "` " <> thing <> " needs "
204+ "The `" <> Name.toString name <> "` " <> thing <> " needs "
205 <> D.args expected <> ", but I see " <> show actual <> " instead:"
205 <> D.args expected <> ", but I see " <> show actual <> " instead:"
207 if actual - expected == 1 then
207 if actual - expected == 1 then
@@ -215,7 +215,7 @@ toReport source err =
215 Report.toCodeSnippet source region Nothing
215 Report.toCodeSnippet source region Nothing
217 D.reflow $
217 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."
221 "I do not know how to group these expressions. Add parentheses for me!"
221 "I do not know how to group these expressions. Add parentheses for me!"
@@ -223,59 +223,59 @@ toReport source err =
224 DuplicateDecl name r1 r2 ->
224 DuplicateDecl name r1 r2 ->
225 nameClash source r1 r2 $
225 nameClash source r1 r2 $
226− "This file has multiple `" <> N.toString name <> "` declarations."
226+ "This file has multiple `" <> Name.toString name <> "` declarations."
228 DuplicateType name r1 r2 ->
228 DuplicateType name r1 r2 ->
229 nameClash source r1 r2 $
229 nameClash source r1 r2 $
230− "This file defines multiple `" <> N.toString name <> "` types."
230+ "This file defines multiple `" <> Name.toString name <> "` types."
232 DuplicateCtor name r1 r2 ->
232 DuplicateCtor name r1 r2 ->
233 nameClash source r1 r2 $
233 nameClash source r1 r2 $
234− "This file defines multiple `" <> N.toString name <> "` type constructors."
234+ "This file defines multiple `" <> Name.toString name <> "` type constructors."
236 DuplicateBinop name r1 r2 ->
236 DuplicateBinop name r1 r2 ->
237 nameClash source r1 r2 $
237 nameClash source r1 r2 $
238− "This file defines multiple (" <> N.toString name <> ") operators."
238+ "This file defines multiple (" <> Name.toString name <> ") operators."
240 DuplicateField name r1 r2 ->
240 DuplicateField name r1 r2 ->
241 nameClash source r1 r2 $
241 nameClash source r1 r2 $
242− "This record has multiple `" <> N.toString name <> "` fields."
242+ "This record has multiple `" <> Name.toString name <> "` fields."
244 DuplicateAliasArg typeName name r1 r2 ->
244 DuplicateAliasArg typeName name r1 r2 ->
245 nameClash source r1 r2 $
245 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."
248 DuplicateUnionArg typeName name r1 r2 ->
248 DuplicateUnionArg typeName name r1 r2 ->
249 nameClash source r1 r2 $
249 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."
252 DuplicatePattern context name r1 r2 ->
252 DuplicatePattern context name r1 r2 ->
253 nameClash source r1 r2 $
253 nameClash source r1 r2 $
254 case context of
254 case context of
255 DPLambdaArgs ->
255 DPLambdaArgs ->
256− "This anonymous function has multiple `" <> N.toString name <> "` arguments."
256+ "This anonymous function has multiple `" <> Name.toString name <> "` arguments."
258 DPFuncArgs funcName ->
258 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."
261 DPCaseBranch ->
261 DPCaseBranch ->
262− "This `case` pattern has multiple `" <> N.toString name <> "` variables."
262+ "This `case` pattern has multiple `" <> Name.toString name <> "` variables."
264 DPLetBinding ->
264 DPLetBinding ->
265− "This `let` expression defines `" <> N.toString name <> "` more than once!"
265+ "This `let` expression defines `" <> Name.toString name <> "` more than once!"
267 DPDestruct ->
267 DPDestruct ->
268− "This pattern contains multiple `" <> N.toString name <> "` variables."
268+ "This pattern contains multiple `" <> Name.toString name <> "` variables."
270 EffectNotFound region name ->
270 EffectNotFound region name ->
271 Report.Report "EFFECT PROBLEM" region [] $
271 Report.Report "EFFECT PROBLEM" region [] $
272 Report.toCodeSnippet source region Nothing
272 Report.toCodeSnippet source region Nothing
274 D.reflow $
274 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:"
277 D.reflow $
277 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!"
281 EffectFunctionNotFound region name ->
281 EffectFunctionNotFound region name ->
@@ -283,17 +283,17 @@ toReport source err =
283 Report.toCodeSnippet source region Nothing
283 Report.toCodeSnippet source region Nothing
285 D.reflow $
285 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."
288 D.reflow $
288 D.reflow $
289− "But I cannot find `" ++ N.toString name ++ "` in this file!"
289+ "But I cannot find `" ++ Name.toString name ++ "` in this file!"
293 ExportDuplicate name r1 r2 ->
293 ExportDuplicate name r1 r2 ->
295 messageThatEndsWithPunctuation =
295 messageThatEndsWithPunctuation =
296− "You are trying to expose `" <> N.toString name <> "` multiple times!"
296+ "You are trying to expose `" <> Name.toString name <> "` multiple times!"
298 Report.Report "REDUNDANT EXPORT" r2 [] $
298 Report.Report "REDUNDANT EXPORT" r2 [] $
299 Report.toCodePair source r1 r2
299 Report.toCodePair source r1 r2
@@ -313,8 +313,8 @@ toReport source err =
313 ExportNotFound region kind rawName possibleNames ->
313 ExportNotFound region kind rawName possibleNames ->
315 suggestions =
315 suggestions =
316− map N.toString $ take 4 $
316+ map Name.toString $ take 4 $
317− Suggest.sort (N.toString rawName) N.toString possibleNames
317+ Suggest.sort (Name.toString rawName) Name.toString possibleNames
319 Report.Report "UNKNOWN EXPORT" region suggestions $
319 Report.Report "UNKNOWN EXPORT" region suggestions $
320 let (a, thing, name) = toKindInfo kind rawName in
320 let (a, thing, name) = toKindInfo kind rawName in
@@ -344,7 +344,7 @@ toReport source err =
345 D.reflow $
345 D.reflow $
346 "The (..) syntax is for exposing union type constructors. It cannot be used with a type alias like `"
346 "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."
349 D.reflow $
349 D.reflow $
350 "Remove the (..) and you should be fine!"
350 "Remove the (..) and you should be fine!"
@@ -355,7 +355,7 @@ toReport source err =
355 Report.toCodeSnippet source region Nothing
355 Report.toCodeSnippet source region Nothing
357 D.reflow $
357 D.reflow $
358− "You are trying to import the `" <> N.toString ctor
358+ "You are trying to import the `" <> Name.toString ctor
359 <> "` type constructor by name:"
359 <> "` type constructor by name:"
361 D.fillSep
361 D.fillSep
@@ -375,7 +375,7 @@ toReport source err =
375 Report.toCodeSnippet source region Nothing
375 Report.toCodeSnippet source region Nothing
377 D.reflow $
377 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!"
@@ -385,7 +385,7 @@ toReport source err =
385 Report.toCodeSnippet source region Nothing
385 Report.toCodeSnippet source region Nothing
387 D.reflow $
387 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:"
391 [ "Remove the (..) and it should work."
391 [ "Remove the (..) and it should work."
@@ -399,16 +399,16 @@ toReport source err =
399 ImportExposingNotFound region (ModuleName.Canonical _ home) value possibleNames ->
399 ImportExposingNotFound region (ModuleName.Canonical _ home) value possibleNames ->
401 suggestions =
401 suggestions =
402− map N.toString $ take 4 $
402+ map Name.toString $ take 4 $
403− Suggest.sort (N.toString home) N.toString possibleNames
403+ Suggest.sort (Name.toString home) Name.toString possibleNames
405 Report.Report "BAD IMPORT" region suggestions $
405 Report.Report "BAD IMPORT" region suggestions $
406 Report.toCodeSnippet source region Nothing
406 Report.toCodeSnippet source region Nothing
408 D.reflow $
408 D.reflow $
409− "The `" <> N.toString home
409+ "The `" <> Name.toString home
410 <> "` module does not expose `"
410 <> "` module does not expose `"
411− <> N.toString value <> "`:"
411+ <> Name.toString value <> "`:"
413 case map D.fromString suggestions of
413 case map D.fromString suggestions of
@@ -454,7 +454,7 @@ toReport source err =
454 [ D.reflow "Switch to (/=) instead."
454 [ D.reflow "Switch to (/=) instead."
455 , D.toSimpleNote $
455 , D.toSimpleNote $
456 "Our (/=) operator is supposed to look like a real “not equal” sign (≠). I hope that history will remember ("
456 "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."
@@ -491,8 +491,8 @@ toReport source err =
493 suggestions =
493 suggestions =
494− map N.toString $ take 2 $
494+ map Name.toString $ take 2 $
495− Suggest.sort (N.toString op) N.toString (Set.toList locals)
495+ Suggest.sort (Name.toString op) Name.toString (Set.toList locals)
497 format altOp =
497 format altOp =
498 D.green $ "(" <> altOp <> ")"
498 D.green $ "(" <> altOp <> ")"
@@ -501,7 +501,7 @@ toReport source err =
501 Report.toCodeSnippet source region Nothing
501 Report.toCodeSnippet source region Nothing
503 D.reflow $
503 D.reflow $
504− "I do not recognize the (" ++ N.toString op ++ ") operator."
504+ "I do not recognize the (" ++ Name.toString op ++ ") operator."
506 D.fillSep $
506 D.fillSep $
507 ["Is","there","an","`import`","and","`exposing`","entry","for","it?"]
507 ["Is","there","an","`import`","and","`exposing`","entry","for","it?"]
@@ -519,7 +519,7 @@ toReport source err =
519 Report.toCodeSnippet source region Nothing
519 Report.toCodeSnippet source region Nothing
521 D.reflow $
521 D.reflow $
522− "You can construct records by using `" <> N.toString name
522+ "You can construct records by using `" <> Name.toString name
523 <> "` as a function, but it is not available in pattern matching like this:"
523 <> "` as a function, but it is not available in pattern matching like this:"
525 D.reflow $
525 D.reflow $
@@ -533,7 +533,7 @@ toReport source err =
533 Report.toCodeSnippet source region Nothing
533 Report.toCodeSnippet source region Nothing
535 D.reflow $
535 D.reflow $
536− "The `" <> N.toString portName <> "` port is trying to transmit " <> aBadKindOfThing <> ":"
536+ "The `" <> Name.toString portName <> "` port is trying to transmit " <> aBadKindOfThing <> ":"
539 [ elaboration
539 [ elaboration
@@ -570,14 +570,14 @@ toReport source err =
570 "an unspecified type"
570 "an unspecified type"
572 D.reflow $
572 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.\
574 \ I need to know exactly what type of data I am getting, so I can guarantee that\
574 \ I need to know exactly what type of data I am getting, so I can guarantee that\
575 \ unexpected data cannot sneak in and crash the Elm program."
575 \ unexpected data cannot sneak in and crash the Elm program."
578 UnsupportedType name ->
578 UnsupportedType name ->
580− "a `" <> N.toString name <> "` value"
580+ "a `" <> Name.toString name <> "` value"
583 [ D.reflow $ "I cannot handle that. The types that CAN flow in and out of Elm include:"
583 [ D.reflow $ "I cannot handle that. The types that CAN flow in and out of Elm include:"
@@ -611,7 +611,7 @@ toReport source err =
611 case portProblem of
611 case portProblem of
612 CmdNoArg ->
612 CmdNoArg ->
614− "The `" <> N.toString name <> "` port cannot be just a command."
614+ "The `" <> Name.toString name <> "` port cannot be just a command."
616 D.reflow $
616 D.reflow $
617 "It can be (() -> Cmd msg) if you just need to trigger a JavaScript\
617 "It can be (() -> Cmd msg) if you just need to trigger a JavaScript\
@@ -620,7 +620,7 @@ toReport source err =
621 CmdExtraArgs n ->
621 CmdExtraArgs n ->
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."
626 theseItemsInSomething
626 theseItemsInSomething
@@ -634,7 +634,7 @@ toReport source err =
635 CmdBadMsg ->
635 CmdBadMsg ->
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."
639 D.reflow $
639 D.reflow $
640 "It must produce a (Cmd msg) type. Notice the lower case `msg` type\
640 "It must produce a (Cmd msg) type. Notice the lower case `msg` type\
@@ -643,13 +643,13 @@ toReport source err =
645 SubBad ->
645 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."
649 [ D.reflow $
649 [ D.reflow $
650 "To receive messages from JavaScript, you need to define a port like this:"
650 "To receive messages from JavaScript, you need to define a port like this:"
651 , D.indent 4 $ D.dullyellow $ D.fromString $
651 , 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"
653 , D.reflow $
653 , D.reflow $
654 "Now every time JS sends an `Int` to this port, it is converted to a `msg`.\
654 "Now every time JS sends an `Int` to this port, it is converted to a `msg`.\
655 \ And if you subscribe, those `msg` values will be piped into your `update`\
655 \ And if you subscribe, those `msg` values will be piped into your `update`\
@@ -659,7 +659,7 @@ toReport source err =
660 NotCmdOrSub ->
660 NotCmdOrSub ->
662− "I am confused about the `" <> N.toString name <> "` port declaration."
662+ "I am confused about the `" <> Name.toString name <> "` port declaration."
664 D.reflow $
664 D.reflow $
665 "Ports need to produce a command (Cmd) or a subscription (Sub) but\
665 "Ports need to produce a command (Cmd) or a subscription (Sub) but\
@@ -693,16 +693,16 @@ toReport source err =
695 D.reflow $
695 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."
699 [ makeTheory "Are you are trying to mutate a variable?" $
699 [ makeTheory "Are you are trying to mutate a variable?" $
700− "Elm does not have mutation, so when I see " ++ N.toString name
700+ "Elm does not have mutation, so when I see " ++ Name.toString name
701− ++ " defined in terms of " ++ N.toString name
701+ ++ " defined in terms of " ++ Name.toString name
702 ++ ", I treat it as a recursive definition. Try giving the new value a new name!"
702 ++ ", I treat it as a recursive definition. Try giving the new value a new name!"
703 , makeTheory "Maybe you DO want a recursive value?" $
703 , makeTheory "Maybe you DO want a recursive value?" $
704− "To define " ++ N.toString name ++ " 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 " ++ N.toString name
705+ ++ " is, so let’s expand it. Wait, but now we need to know what " ++ Name.toString name
706 ++ " is, so let’s expand it... This will keep going infinitely!"
706 ++ " is, so let’s expand it... This will keep going infinitely!"
707 , D.link "Hint"
707 , D.link "Hint"
708 "The root problem is often a typo in some variable name, but I recommend reading"
708 "The root problem is often a typo in some variable name, but I recommend reading"
@@ -714,11 +714,11 @@ toReport source err =
716 D.reflow $
716 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."
720 [ D.reflow $
720 [ D.reflow $
721− "The `" <> N.toString name
721+ "The `" <> Name.toString name
722 <> "` value depends on itself through the following chain of definitions:"
722 <> "` value depends on itself through the following chain of definitions:"
723 , D.cycle 4 (name:names)
723 , D.cycle 4 (name:names)
724 , D.link "Hint"
724 , D.link "Hint"
@@ -739,16 +739,16 @@ toReport source err =
741 D.reflow $
741 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."
745 [ makeTheory "Are you are trying to mutate a variable?" $
745 [ makeTheory "Are you are trying to mutate a variable?" $
746− "Elm does not have mutation, so when I see " ++ N.toString name
746+ "Elm does not have mutation, so when I see " ++ Name.toString name
747− ++ " defined in terms of " ++ N.toString name
747+ ++ " defined in terms of " ++ Name.toString name
748 ++ ", I treat it as a recursive definition. Try giving the new value a new name!"
748 ++ ", I treat it as a recursive definition. Try giving the new value a new name!"
749 , makeTheory "Maybe you DO want a recursive value?" $
749 , makeTheory "Maybe you DO want a recursive value?" $
750− "To define " ++ N.toString name ++ " 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 " ++ N.toString name
751+ ++ " is, so let’s expand it. Wait, but now we need to know what " ++ Name.toString name
752 ++ " is, so let’s expand it... This will keep going infinitely!"
752 ++ " is, so let’s expand it... This will keep going infinitely!"
753 , D.link "Hint"
753 , D.link "Hint"
754 "The root problem is often a typo in some variable name, but I recommend reading"
754 "The root problem is often a typo in some variable name, but I recommend reading"
@@ -764,7 +764,7 @@ toReport source err =
766 [ D.reflow $
766 [ D.reflow $
767− "The `" <> N.toString name
767+ "The `" <> Name.toString name
768 <> "` value depends on itself through the following chain of definitions:"
768 <> "` value depends on itself through the following chain of definitions:"
769 , D.cycle 4 (name:names)
769 , D.cycle 4 (name:names)
770 , D.link "Hint"
770 , D.link "Hint"
@@ -780,7 +780,7 @@ toReport source err =
780 ( "These variables cannot have the same name:"
780 ( "These variables cannot have the same name:"
783− ( D.reflow $ "The name `" <> N.toString name <> "` is first defined here:"
783+ ( D.reflow $ "The name `" <> Name.toString name <> "` is first defined here:"
784 , "But then it is defined AGAIN over here:"
784 , "But then it is defined AGAIN over here:"
@@ -902,7 +902,7 @@ toReport source err =
902 Report.toCodeSnippet source aliasRegion Nothing
902 Report.toCodeSnippet source aliasRegion Nothing
904 D.reflow $
904 D.reflow $
905− "Type alias `" <> N.toString typeName <> "` has some type variable problems."
905+ "Type alias `" <> Name.toString typeName <> "` has some type variable problems."
908 [ D.fillSep $ theseAreUsed ++ butTheseAreUnused
908 [ D.fillSep $ theseAreUsed ++ butTheseAreUnused
@@ -921,7 +921,7 @@ toReport source err =
921-- BAD TYPE VARIABLES
921-- BAD TYPE VARIABLES
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
925unboundTypeVars source declRegion tipe typeName allVars (unboundVar, varRegion) unboundVars =
925unboundTypeVars source declRegion tipe typeName allVars (unboundVar, varRegion) unboundVars =
927 backQuote name =
927 backQuote name =
@@ -960,7 +960,7 @@ unboundTypeVars source declRegion tipe typeName allVars (unboundVar, varRegion)
960 ++ map (D.green . D.fromName) (unboundVar : map fst unboundVars)
960 ++ map (D.green . D.fromName) (unboundVar : map fst unboundVars)
961 ++ ["=", "..."]
961 ++ ["=", "..."]
962 , D.reflow $
962 , 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 ++
964 "` is an Int and another where it is a Bool. When we explicitly list the type\
964 "` is an Int and another where it is a Bool. When we explicitly list the type\
965 \ variables, the type checker can see that they are actually different types."
965 \ variables, the type checker can see that they are actually different types."
@@ -993,7 +993,7 @@ nameClash source r1 r2 messageThatEndsWithPunctuation =
993-- AMBIGUOUS NAME
993-- AMBIGUOUS NAME
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
997ambiguousName source region maybePrefix name possibleHomes thing =
997ambiguousName source region maybePrefix name possibleHomes thing =
998 Report.Report "AMBIGUOUS NAME" region [] $
998 Report.Report "AMBIGUOUS NAME" region [] $
999 Report.toCodeSnippet source region Nothing $
999 Report.toCodeSnippet source region Nothing $
@@ -1007,12 +1007,12 @@ ambiguousName source region maybePrefix name possibleHomes thing =
1007 if length possibleHomes == 2 then "both" else "all"
1007 if length possibleHomes == 2 then "both" else "all"
1010− D.reflow $ "This usage of `" ++ N.toString name ++ "` is ambiguous."
1010+ D.reflow $ "This usage of `" ++ Name.toString name ++ "` is ambiguous."
1013 [ D.reflow $
1013 [ D.reflow $
1014 "Check your imports. The following modules " ++ bothOrAll
1014 "Check your imports. The following modules " ++ bothOrAll
1015− ++ " expose a `" ++ N.toString name ++ "` " ++ thing ++ ":"
1015+ ++ " expose a `" ++ Name.toString name ++ "` " ++ thing ++ ":"
1016 , D.indent 4 $ D.vcat $ map homeToYellowDoc possibleHomes
1016 , D.indent 4 $ D.vcat $ map homeToYellowDoc possibleHomes
1017 , D.reflowLink "Read" "imports" "to learn how to clarify which one you want."
1017 , D.reflowLink "Read" "imports" "to learn how to clarify which one you want."
@@ -1046,18 +1046,18 @@ ambiguousName source region maybePrefix name possibleHomes thing =
1046-- NOT FOUND
1046-- NOT FOUND
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
1050notFound source region maybePrefix name thing (PossibleNames locals quals) =
1050notFound source region maybePrefix name thing (PossibleNames locals quals) =
1052 givenName =
1052 givenName =
1053− maybe N.toString toQualString maybePrefix name
1053+ maybe Name.toString toQualString maybePrefix name
1055 possibleNames =
1055 possibleNames =
1057 addQuals prefix localSet allNames =
1057 addQuals prefix localSet allNames =
1058 Set.foldr (\x xs -> toQualString prefix x : xs) allNames localSet
1058 Set.foldr (\x xs -> toQualString prefix x : xs) allNames localSet
1060− Map.foldrWithKey addQuals (map N.toString (Set.toList locals)) quals
1060+ Map.foldrWithKey addQuals (map Name.toString (Set.toList locals)) quals
1062 nearbyNames =
1062 nearbyNames =
1063 take 4 (Suggest.sort givenName id possibleNames)
1063 take 4 (Suggest.sort givenName id possibleNames)
@@ -1094,19 +1094,19 @@ notFound source region maybePrefix name thing (PossibleNames locals quals) =
1094 case Map.lookup prefix quals of
1094 case Map.lookup prefix quals of
1095 Nothing ->
1095 Nothing ->
1096 toDetails
1096 toDetails
1097− ("I cannot find a `" ++ N.toString prefix ++ "` module. Is there an `import` for it?")
1097+ ("I cannot find a `" ++ Name.toString prefix ++ "` module. Is there an `import` for it?")
1098− ("I cannot find a `" ++ N.toString prefix ++ "` import. These names seem close though:")
1098+ ("I cannot find a `" ++ Name.toString prefix ++ "` import. These names seem close though:")
1100 Just _ ->
1100 Just _ ->
1101 toDetails
1101 toDetails
1102− ("The `" ++ N.toString prefix ++ "` module does not expose a `" ++ N.toString name ++ "` " ++ thing ++ ".")
1102+ ("The `" ++ Name.toString prefix ++ "` module does not expose a `" ++ Name.toString name ++ "` " ++ thing ++ ".")
1103− ("The `" ++ N.toString prefix ++ "` module does not expose a `" ++ N.toString name ++ "` " ++ thing ++ ". These names seem close though:")
1103+ ("The `" ++ Name.toString prefix ++ "` module does not expose a `" ++ Name.toString name ++ "` " ++ thing ++ ". These names seem close though:")
1107−toQualString :: N.Name -> N.Name -> String
1107+toQualString :: Name.Name -> Name.Name -> String
1108toQualString prefix name =
1108toQualString prefix name =
1109− N.toString prefix ++ "." ++ N.toString name
1109+ Name.toString prefix ++ "." ++ Name.toString name
@@ -1200,7 +1200,7 @@ modHint =
1200-- ARG MISMATCH
1200-- ARG MISMATCH
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
1204_argMismatchReport source region kind name expected actual =
1204_argMismatchReport source region kind name expected actual =
1206 numArgs =
1206 numArgs =
@@ -1212,7 +1212,7 @@ _argMismatchReport source region kind name expected actual =
1212 Report.toCodeSnippet source region Nothing
1212 Report.toCodeSnippet source region Nothing
1214 D.reflow $
1214 D.reflow $
1215− kind <> " " <> N.toString name <> " has " <> numArgs <> "."
1215+ kind <> " " <> Name.toString name <> " has " <> numArgs <> "."
1217 D.reflow $
1217 D.reflow $
1218 "Expecting " <> show expected <> ", but got " <> show actual <> "."
1218 "Expecting " <> show expected <> ", but got " <> show actual <> "."
@@ -1223,7 +1223,7 @@ _argMismatchReport source region kind name expected actual =
1223-- BAD ALIAS RECURSION
1223-- BAD ALIAS RECURSION
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
1227aliasRecursionReport source region name args tipe others =
1227aliasRecursionReport source region name args tipe others =
1228 case others of
1228 case others of
@@ -1262,7 +1262,7 @@ aliasRecursionReport source region name args tipe others =
1265−aliasToUnionDoc :: N.Name -> [N.Name] -> Src.Type -> Doc
1265+aliasToUnionDoc :: Name.Name -> [Name.Name] -> Src.Type -> Doc
1266aliasToUnionDoc name args tipe =
1266aliasToUnionDoc name args tipe =
1268 [ D.dullyellow $
1268 [ D.dullyellow $