on master help sign in
Switch Reporting/ over to Data.Name
commit2fb73b71fc7d6eaf79984e48d5f6c3fdf3103c3d authorEvan Czaplicki <evancz@users.noreply.github.com> dateMon 19 Nov 2018, 13:27 (8 years ago) parent69224e3
10 files changed+276−268
compiler/src/Reporting/Doc.hs+11−5 compiler/src/Reporting/Error/Canonicalize.hs+121−121 compiler/src/Reporting/Error/Docs.hs+15−14 compiler/src/Reporting/Error/Main.hs+5−4 compiler/src/Reporting/Error/Pattern.hs+2−2 compiler/src/Reporting/Error/Syntax.hs+20−20 compiler/src/Reporting/Error/Type.hs+73−73 compiler/src/Reporting/Render/Type.hs+3−3 compiler/src/Reporting/Render/Type/Localizer.hs+16−16 compiler/src/Reporting/Warning.hs+10−10
compiler/src/Reporting/Doc.hs+11−5
@@ -8,7 +8,7 @@ module Reporting.Doc
88 , P.red, P.cyan, P.magenta, P.green, P.blue, P.black, P.yellow
99 , P.dullred, P.dullcyan, P.dullyellow
1010
11− , fromString, fromText, fromName, fromInt
11+ , fromString, fromText, fromName, fromInt, fromUtf8
1212 , toAnsi, toString, toLine
1313 , encode
1414
@@ -25,10 +25,11 @@ module Reporting.Doc
2525import Prelude hiding (cycle)
2626import qualified Data.List as List
2727import Data.Monoid ((<>))
28+import qualified Data.Name as Name
2829import qualified Data.Text as Text
2930import qualified Data.Text.Lazy as TL
3031import qualified Data.Text.Lazy.Builder as TB
31−import qualified Elm.Name as N
32+import qualified Data.Utf8 as Utf8
3233import qualified System.Console.ANSI.Types as Ansi
3334import System.IO (Handle)
3435import qualified Text.PrettyPrint.ANSI.Leijen as P
@@ -53,9 +54,9 @@ fromText txt =
5354 P.text (Text.unpack txt)
5455
5556
56−fromName :: N.Name -> P.Doc
57+fromName :: Name.Name -> P.Doc
5758fromName name =
58− P.text (N.toString name)
59+ P.text (Name.toString name)
5960
6061
6162fromInt :: Int -> P.Doc
@@ -63,6 +64,11 @@ fromInt n =
6364 P.text (show n)
6465
6566
67+fromUtf8 :: Utf8.Utf8 -> P.Doc
68+fromUtf8 utf8 =
69+ P.text (Utf8.toString utf8)
70+
71+
6672
6773-- TO STRING
6874
@@ -208,7 +214,7 @@ intToOrdinal number =
208214
209215
210216
211−cycle :: Int -> [N.Name] -> P.Doc
217+cycle :: Int -> [Name.Name] -> P.Doc
212218cycle indent names =
213219 let
214220 topLine = "┌─────┐"
compiler/src/Reporting/Error/Canonicalize.hs+121−121
@@ -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 $
compiler/src/Reporting/Error/Docs.hs+15−14
@@ -7,7 +7,8 @@ module Reporting.Error.Docs
77 where
88
99
10−import qualified Elm.Name as N
10+import qualified Data.Name as Name
11+
1112import Reporting.Doc ((<>))
1213import qualified Reporting.Doc as D
1314import qualified Reporting.Region as R
@@ -19,11 +20,11 @@ import qualified Reporting.Report as Report
1920data Error
2021 = NoDocs R.Region
2122 | ImplicitExposing R.Region
22− | Duplicate N.Name R.Region R.Region
23− | OnlyInDocs N.Name R.Region
24− | OnlyInExports N.Name R.Region
25− | NoComment N.Name R.Region
26− | NoAnnotation N.Name 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
2728
2829
2930
@@ -65,14 +66,14 @@ toReport source err =
6566 Report.toCodePair source r1 r2
6667 (
6768 D.reflow $
68− "There can only be one `" <> N.toString name
69+ "There can only be one `" <> Name.toString name
6970 <> "` in your module documentation, but it is listed twice:"
7071 ,
7172 "Remove one of them!"
7273 )
7374 (
7475 D.reflow $
75− "There can only be one `" <> N.toString name
76+ "There can only be one `" <> Name.toString name
7677 <> "` in your module documentation, but I see two. One here:"
7778 ,
7879 "And another one over here:"
@@ -85,12 +86,12 @@ toReport source err =
8586 Report.toCodeSnippet source region Nothing
8687 (
8788 D.reflow $
88− "I do not see `" <> N.toString name
89+ "I do not see `" <> Name.toString name
8990 <> "` in the `exposing` list, but it is in your module documentation:"
9091 ,
9192 D.reflow $
9293 "Does it need to be added to the `exposing` list as well? Or maybe you removed `"
93− <> N.toString name <> "` and forgot to delete it here?"
94+ <> Name.toString name <> "` and forgot to delete it here?"
9495 )
9596
9697 OnlyInExports name region ->
@@ -98,12 +99,12 @@ toReport source err =
9899 Report.toCodeSnippet source region Nothing
99100 (
100101 D.reflow $
101− "I do not see `" <> N.toString name
102+ "I do not see `" <> Name.toString name
102103 <> "` in your module documentation, but it is in your `exposing` list:"
103104 ,
104105 D.stack
105106 [ D.reflow $
106− "Add a line like `@docs " <> N.toString name
107+ "Add a line like `@docs " <> Name.toString name
107108 <> "` to your module documentation!"
108109 , D.link "Note" "See" "docs" "for more guidance on writing high quality docs."
109110 ]
@@ -114,7 +115,7 @@ toReport source err =
114115 Report.toCodeSnippet source region Nothing
115116 (
116117 D.reflow $
117− "The `" <> N.toString name <> "` definition does not have a documentation comment."
118+ "The `" <> Name.toString name <> "` definition does not have a documentation comment."
118119 ,
119120 D.stack
120121 [ D.reflow $
@@ -128,7 +129,7 @@ toReport source err =
128129 Report.toCodeSnippet source region Nothing
129130 (
130131 D.reflow $
131− "The `" <> N.toString name <> "` definition does not have a type annotation."
132+ "The `" <> Name.toString name <> "` definition does not have a type annotation."
132133 ,
133134 D.stack
134135 [ D.reflow $
compiler/src/Reporting/Error/Main.hs+5−4
@@ -7,8 +7,9 @@ module Reporting.Error.Main
77 where
88
99
10+import qualified Data.Name as Name
11+
1012import qualified AST.Canonical as Can
11−import qualified Elm.Name as N
1213import qualified Reporting.Doc as D
1314import qualified Reporting.Error.Canonicalize as E
1415import qualified Reporting.Region as R
@@ -24,7 +25,7 @@ import qualified Reporting.Report as Report
2425
2526data Error
2627 = BadType R.Region Can.Type
27− | BadCycle R.Region [N.Name]
28+ | BadCycle R.Region [Name.Name]
2829 | BadFlags R.Region Can.Type E.InvalidPayload
2930
3031
@@ -100,14 +101,14 @@ toReport localizer source err =
100101 "an unspecified type"
101102 ,
102103 D.reflow $
103− "But type variables like `" ++ N.toString name ++ "` cannot be given as flags.\
104+ "But type variables like `" ++ Name.toString name ++ "` cannot be given as flags.\
104105 \ I need to know exactly what type of data I am getting, so I can guarantee that\
105106 \ unexpected data cannot sneak in and crash the Elm program."
106107 )
107108
108109 E.UnsupportedType name ->
109110 (
110− "a `" ++ N.toString name ++ "` value"
111+ "a `" ++ Name.toString name ++ "` value"
111112 ,
112113 D.stack
113114 [ D.reflow $ "I cannot handle that. The types that CAN be in flags include:"
compiler/src/Reporting/Error/Pattern.hs+2−2
@@ -117,10 +117,10 @@ patternToDoc context pattern =
117117 NonList (P.Literal literal) ->
118118 case literal of
119119 P.Chr chr ->
120− D.fromText ("'" <> chr <> "'")
120+ "'" <> D.fromUtf8 chr <> "'"
121121
122122 P.Str str ->
123− D.fromText ("\"" <> str <> "\"")
123+ "\"" <> D.fromUtf8 str <> "\""
124124
125125 P.Int int ->
126126 D.fromInt int
compiler/src/Reporting/Error/Syntax.hs+20−20
@@ -13,10 +13,10 @@ module Reporting.Error.Syntax
1313
1414
1515import Data.Monoid ((<>))
16+import qualified Data.Name as Name
1617import qualified Data.Set as Set
1718import qualified Data.Text as Text
1819
19−import qualified Elm.Name as N
2020import qualified Reporting.Doc as D
2121import qualified Reporting.Region as R
2222import qualified Reporting.Render.Code as Code
@@ -29,9 +29,9 @@ import qualified Reporting.Report as Report
2929
3030data Error
3131 = CommentOnNothing R.Region
32− | UnexpectedPort R.Region N.Name
33− | TypeWithBadDefinition R.Region N.Name N.Name
34− | TypeWithoutDefinition R.Region N.Name
32+ | UnexpectedPort R.Region Name.Name
33+ | TypeWithBadDefinition R.Region Name.Name Name.Name
34+ | TypeWithoutDefinition R.Region Name.Name
3535 | Parse R.Region (Maybe R.Region) Problem
3636
3737
@@ -90,7 +90,7 @@ data Theory
9090data Next
9191 = Decl
9292 | Expr
93− | AfterOpExpr N.Name
93+ | AfterOpExpr Name.Name
9494 | ElseBranch
9595 | Arg
9696 | Pattern
@@ -112,8 +112,8 @@ data Context
112112 | ExprTuple
113113 | ExprRecord
114114 ----------------
115− | Definition N.Name
116− | Annotation N.Name
115+ | Definition Name.Name
116+ | Annotation Name.Name
117117 ----------------
118118 | TypeTuple
119119 | TypeRecord
@@ -155,7 +155,7 @@ toReport source err =
155155 Report.toCodeSnippet source region Nothing
156156 (
157157 D.reflow $
158− "You are declaring port `" <> N.toString name <> "` in a normal module."
158+ "You are declaring port `" <> Name.toString name <> "` in a normal module."
159159 ,
160160 D.stack
161161 [ "It needs to be in a `port` module."
@@ -171,9 +171,9 @@ toReport source err =
171171 Report.toCodeSnippet source region Nothing
172172 (
173173 D.reflow $
174− "I see a `" <> N.toString annName
174+ "I see a `" <> Name.toString annName
175175 <> "` annotation, but it is followed by a `"
176− <> N.toString defName <> "` definition."
176+ <> Name.toString defName <> "` definition."
177177 ,
178178 D.fillSep
179179 ["The","annotation","and","definition","names","must","match!"
@@ -189,7 +189,7 @@ toReport source err =
189189 Report.toCodeSnippet source region Nothing
190190 (
191191 D.reflow $
192− "There is a type annotation for `" <> N.toString name
192+ "There is a type annotation for `" <> Name.toString name
193193 <> "` but there is no corresponding definition!"
194194 ,
195195 "Directly below the type annotation, put a definition like:\n\n"
@@ -597,8 +597,8 @@ contextToString defaultString prefixString stack =
597597 ExprList -> "a list" <> anchor
598598 ExprTuple -> "an expression (in parentheses)" <> anchor
599599 ExprRecord -> "a record" <> anchor
600− Definition name -> N.toString name <> "'s definition"
601− Annotation name -> N.toString name <> "'s type annotation"
600+ Definition name -> Name.toString name <> "'s definition"
601+ Annotation name -> Name.toString name <> "'s type annotation"
602602 TypeTuple -> "a type (in parentheses)" <> anchor
603603 TypeRecord -> "a record type" <> anchor
604604 PatternList -> "a list pattern" <> anchor
@@ -621,10 +621,10 @@ getAnchor stack =
621621 (context, _) : rest ->
622622 case context of
623623 Definition name ->
624− " in " <> N.toString name <> "'s definition"
624+ " in " <> Name.toString name <> "'s definition"
625625
626626 Annotation name ->
627− " in " <> N.toString name <> "'s type annotation"
627+ " in " <> Name.toString name <> "'s type annotation"
628628
629629 _ ->
630630 getAnchor rest
@@ -692,7 +692,7 @@ theoryToString context theory =
692692 case next of
693693 Decl -> "a declaration, like `x = 5` or `type alias Model = { ... }`"
694694 Expr -> "an expression, like x or 42"
695− AfterOpExpr op -> "an expression after that (" <> N.toString op <> ") operator, like x or 42"
695+ AfterOpExpr op -> "an expression after that (" <> Name.toString op <> ") operator, like x or 42"
696696 ElseBranch -> "an `else` branch. An `if` must handle both possibilities."
697697 Arg -> "an argument, like `name` or `total`"
698698 Pattern -> "a pattern, like `name` or (Just x)"
@@ -710,7 +710,7 @@ equalsTheory stack =
710710 (context, _) : rest ->
711711 case context of
712712 ExprRecord -> "an equals sign (=) followed by an expression"
713− Definition name -> "an equals sign (=) followed by " <> N.toString name <> "'s definition"
713+ Definition name -> "an equals sign (=) followed by " <> Name.toString name <> "'s definition"
714714 TypeUnion -> "an equals sign (=) followed by the first union type constructor"
715715 TypeAlias -> "an equals sign (=) followed by the aliased type"
716716 _ -> equalsTheory rest
@@ -745,8 +745,8 @@ badSpace stack =
745745 ExprList -> "the end of that list" <> badSpaceExprEnd rest
746746 ExprTuple -> "a closing paren" <> badSpaceExprEnd rest
747747 ExprRecord -> "the end of that record" <> badSpaceExprEnd rest
748− Definition name -> "the rest of " <> N.toString name <> "'s definition" <> badSpaceExprEnd stack
749− Annotation name -> "the rest of " <> N.toString name <> "'s type annotation" <> badSpaceEnd
748+ Definition name -> "the rest of " <> Name.toString name <> "'s definition" <> badSpaceExprEnd stack
749+ Annotation name -> "the rest of " <> Name.toString name <> "'s type annotation" <> badSpaceEnd
750750 TypeTuple -> "a closing paren" <> badSpaceEnd
751751 TypeRecord -> "the end of that record" <> badSpaceEnd
752752 PatternList -> "the end of that list" <> badSpaceEnd
@@ -780,7 +780,7 @@ badSpaceExprEnd stack =
780780 "more indentation? (Try " <> show (column + 1) <> "+ spaces.)"
781781 in
782782 ". Maybe you forgot some code? Or maybe the body of `"
783− <> N.toString name
783+ <> Name.toString name
784784 <> "` needs " <> ending
785785
786786 _ : rest ->
compiler/src/Reporting/Error/Type.hs+73−73
@@ -22,10 +22,10 @@ module Reporting.Error.Type
2222import Prelude hiding (round)
2323import qualified Data.Map as Map
2424import Data.Monoid ((<>))
25+import qualified Data.Name as Name
2526
2627import qualified AST.Canonical as Can
2728import qualified Data.Index as Index
28−import qualified Elm.Name as N
2929import qualified Reporting.Doc as D
3030import qualified Reporting.Region as R
3131import qualified Reporting.Render.Code as Code
@@ -43,7 +43,7 @@ import qualified Type.Error as T
4343data Error
4444 = BadExpr R.Region Category T.Type (Expected T.Type)
4545 | BadPattern R.Region PCategory T.Type (PExpected T.Type)
46− | InfiniteType R.Region N.Name T.Type
46+ | InfiniteType R.Region Name.Name T.Type
4747
4848
4949
@@ -53,22 +53,22 @@ data Error
5353data Expected tipe
5454 = NoExpectation tipe
5555 | FromContext R.Region Context tipe
56− | FromAnnotation N.Name Int SubContext tipe
56+ | FromAnnotation Name.Name Int SubContext tipe
5757
5858
5959data Context
6060 = ListEntry Index.ZeroBased
6161 | Negate
62− | OpLeft N.Name
63− | OpRight N.Name
62+ | OpLeft Name.Name
63+ | OpRight Name.Name
6464 | IfCondition
6565 | IfBranch Index.ZeroBased
6666 | CaseBranch Index.ZeroBased
6767 | CallArity MaybeName Int
6868 | CallArg MaybeName Index.ZeroBased
69− | RecordAccess R.Region (Maybe N.Name) R.Region N.Name
70− | RecordUpdateKeys N.Name (Map.Map N.Name Can.FieldUpdate)
71− | RecordUpdateValue N.Name
69+ | RecordAccess R.Region (Maybe Name.Name) R.Region Name.Name
70+ | RecordUpdateKeys Name.Name (Map.Map Name.Name Can.FieldUpdate)
71+ | RecordUpdateValue Name.Name
7272 | Destructure
7373
7474
@@ -79,9 +79,9 @@ data SubContext
7979
8080
8181data MaybeName
82− = FuncName N.Name
83− | CtorName N.Name
84− | OpName N.Name
82+ = FuncName Name.Name
83+ | CtorName Name.Name
84+ | OpName Name.Name
8585 | NoName
8686
8787
@@ -95,15 +95,15 @@ data Category
9595 | Case
9696 | CallResult MaybeName
9797 | Lambda
98− | Accessor N.Name
99− | Access N.Name
98+ | Accessor Name.Name
99+ | Access Name.Name
100100 | Record
101101 | Tuple
102102 | Unit
103103 | Shader
104104 | Effects
105− | Local N.Name
106− | Foreign N.Name
105+ | Local Name.Name
106+ | Foreign Name.Name
107107
108108
109109
@@ -116,9 +116,9 @@ data PExpected tipe
116116
117117
118118data PContext
119− = PTypedArg N.Name Index.ZeroBased
119+ = PTypedArg Name.Name Index.ZeroBased
120120 | PCaseMatch Index.ZeroBased
121− | PCtorArg N.Name Index.ZeroBased
121+ | PCtorArg Name.Name Index.ZeroBased
122122 | PListEntry Index.ZeroBased
123123 | PTail
124124
@@ -128,7 +128,7 @@ data PCategory
128128 | PUnit
129129 | PTuple
130130 | PList
131− | PCtor N.Name
131+ | PCtor Name.Name
132132 | PInt
133133 | PStr
134134 | PChr
@@ -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 `" <> N.toString name <> "` is weird."
204+ "The " <> D.ordinal index <> " argument to `" <> Name.toString name <> "` is weird."
205205 , patternTypeComparison localizer tipe expectedType
206206 (addPatternCategory "The argument is a pattern that matches" category)
207− ( "But the type annotation on `" <> N.toString name
207+ ( "But the type annotation on `" <> Name.toString 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 `" <> N.toString name <> "` is weird."
241+ "The " <> D.ordinal index <> " argument to `" <> Name.toString name <> "` is weird."
242242 , patternTypeComparison localizer tipe expectedType
243243 (addPatternCategory "It is trying to match" category)
244− ( "But `" <> N.toString name <> "` needs its "
244+ ( "But `" <> Name.toString 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 -> " `" <> N.toString name <> "` values of type:"
302+ PCtor name -> " `" <> Name.toString 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 `" <> N.toString name <> "` value is a:"
347− Foreign name -> "This `" <> N.toString name <> "` value is a:"
348− Access field -> "The value at ." <> N.toString field <> " is a:"
349− Accessor field -> "This ." <> N.toString field <> " field access function has type:"
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:"
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 `" <> N.toString name <> "` call produces:"
367− CtorName name -> "This `" <> N.toString name <> "` call produces:"
366+ FuncName name -> "This `" <> Name.toString name <> "` call produces:"
367+ CtorName name -> "This `" <> Name.toString 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 `" ++ N.toString n ++ "` value")
465+ T.Type _ n _ -> badRigidVar x ("a `" ++ Name.toString 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 `" ++ N.toString n ++ "` value")
469+ T.Alias _ n _ _ -> badRigidVar x ("a `" ++ Name.toString 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 `" ++ N.toString n ++ "` value")
480+ T.Type _ n _ -> badRigidSuper super ("a `" ++ Name.toString 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 `" ++ N.toString n ++ "` value")
484+ T.Alias _ n _ _ -> badRigidSuper super ("a `" ++ Name.toString 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 (N.toString typo) N.toString possibilities of
502+ case Suggest.sort (Name.toString typo) Name.toString possibilities of
503503 [] ->
504504 []
505505
@@ -519,10 +519,10 @@ problemToHint problem =
519519-- BAD RIGID HINTS
520520
521521
522−badRigidVar :: N.Name -> String -> [D.Doc]
522+badRigidVar :: Name.Name -> String -> [D.Doc]
523523badRigidVar name aThing =
524524 [ D.toSimpleHint $
525− "Your type annotation uses type variable `" ++ N.toString name ++
525+ "Your type annotation uses type variable `" ++ Name.toString 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?"
@@ -530,10 +530,10 @@ badRigidVar name aThing =
530530 ]
531531
532532
533−badDoubleRigid :: N.Name -> N.Name -> [D.Doc]
533+badDoubleRigid :: Name.Name -> Name.Name -> [D.Doc]
534534badDoubleRigid x y =
535535 [ D.toSimpleHint $
536− "Your type annotation uses `" ++ N.toString x ++ "` and `" ++ N.toString y ++
536+ "Your type annotation uses `" ++ Name.toString x ++ "` and `" ++ Name.toString 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?"
@@ -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 `" <> N.toString name <> "` definition:"
647+ TypedBody -> "body of the `" <> Name.toString 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 `" <> N.toString name <> "` says it should be:")
660+ ("But the type annotation on `" <> Name.toString 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 `" <> N.toString name <> "` value"
773− CtorName name -> "The `" <> N.toString name <> "` value"
774− OpName op -> "The (" <> N.toString op <> ") operator"
772+ FuncName name -> "The `" <> Name.toString name <> "` value"
773+ CtorName name -> "The `" <> Name.toString name <> "` value"
774+ OpName op -> "The (" <> Name.toString 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 `" <> N.toString name <> "` function"
786− CtorName name -> "The `" <> N.toString name <> "` constructor"
787− OpName op -> "The (" <> N.toString op <> ") operator"
785+ FuncName name -> "The `" <> Name.toString name <> "` function"
786+ CtorName name -> "The `" <> Name.toString name <> "` constructor"
787+ OpName op -> "The (" <> Name.toString 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 -> "`" <> N.toString name <> "`"
801− CtorName name -> "`" <> N.toString name <> "`"
802− OpName op -> "(" <> N.toString op <> ")"
800+ FuncName name -> "`" <> Name.toString name <> "`"
801+ CtorName name -> "`" <> Name.toString name <> "`"
802+ OpName op -> "(" <> Name.toString 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 -> "`" <> N.toString n <> "`") maybeName
827− <> " record does not have a `" <> N.toString field <> "` field:"
828− , case Suggest.sort (N.toString field) (N.toString . fst) (Map.toList fields) of
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
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 -> "`" <> N.toString n <> "`") maybeName
836+ <> maybe "" (\n -> "`" <> Name.toString 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 `" <> N.toString record <> "` record is"
866+ , "The `" <> Name.toString 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 = "`" <> N.toString record <> "`"
878− fStr = "`" <> N.toString field <> "`"
877+ rStr = "`" <> Name.toString record <> "`"
878+ fStr = "`" <> Name.toString field <> "`"
879879 in
880880 custom (Just fieldRegion)
881881 ( D.reflow $
882882 "The " <> rStr <> " record does not have a " <> fStr <> " field:"
883− , case Suggest.sort (N.toString field) (N.toString . fst) (Map.toList actualFields) of
883+ , case Suggest.sort (Name.toString field) (Name.toString . 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 `" <> N.toString field <> "` field like this:"
912− , "You are trying to update `" <> N.toString field <> "` to be"
911+ , "I cannot update the `" <> Name.toString field <> "` field like this:"
912+ , "You are trying to update `" <> Name.toString 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.\
@@ -945,7 +945,7 @@ countArgs tipe =
945945-- FIELD NAME HELPERS
946946
947947
948−toNearbyRecord :: L.Localizer -> (N.Name, T.Type) -> [(N.Name, T.Type)] -> T.Extension -> D.Doc
948+toNearbyRecord :: L.Localizer -> (Name.Name, T.Type) -> [(Name.Name, T.Type)] -> T.Extension -> D.Doc
949949toNearbyRecord localizer f fs ext =
950950 D.indent 4 $
951951 if length fs <= 3 then
@@ -954,7 +954,7 @@ toNearbyRecord localizer f fs ext =
954954 RT.vrecordSnippet (fieldToDocs localizer f) (map (fieldToDocs localizer) (take 3 fs))
955955
956956
957−fieldToDocs :: L.Localizer -> (N.Name, T.Type) -> (D.Doc, D.Doc)
957+fieldToDocs :: L.Localizer -> (Name.Name, T.Type) -> (D.Doc, D.Doc)
958958fieldToDocs localizer (name, tipe) =
959959 ( D.fromName name
960960 , T.toDoc localizer RT.None tipe
@@ -973,7 +973,7 @@ extToDoc ext =
973973-- OP LEFT
974974
975975
976−opLeftToDocs :: L.Localizer -> Category -> N.Name -> T.Type -> T.Type -> (D.Doc, D.Doc)
976+opLeftToDocs :: L.Localizer -> Category -> Name.Name -> T.Type -> T.Type -> (D.Doc, D.Doc)
977977opLeftToDocs localizer category op tipe expected =
978978 case op of
979979 "+"
@@ -1008,10 +1008,10 @@ opLeftToDocs localizer category op tipe expected =
10081008
10091009 _ ->
10101010 ( D.reflow $
1011− "The left argument of (" <> N.toString op <> ") is causing problems:"
1011+ "The left argument of (" <> Name.toString op <> ") is causing problems:"
10121012 , typeComparison localizer tipe expected
10131013 (addCategory "The left argument is" category)
1014− ("But (" <> N.toString op <> ") needs the left argument to be:")
1014+ ("But (" <> Name.toString op <> ") needs the left argument to be:")
10151015 []
10161016 )
10171017
@@ -1025,7 +1025,7 @@ data RightDocs
10251025 | EmphRight (D.Doc, D.Doc)
10261026
10271027
1028−opRightToDocs :: L.Localizer -> Category -> N.Name -> T.Type -> T.Type -> RightDocs
1028+opRightToDocs :: L.Localizer -> Category -> Name.Name -> T.Type -> T.Type -> RightDocs
10291029opRightToDocs localizer category op tipe expected =
10301030 case op of
10311031 "+"
@@ -1099,16 +1099,16 @@ opRightToDocs localizer category op tipe expected =
10991099 badOpRightFallback localizer category op tipe expected
11001100
11011101
1102−badOpRightFallback :: L.Localizer -> Category -> N.Name -> T.Type -> T.Type -> RightDocs
1102+badOpRightFallback :: L.Localizer -> Category -> Name.Name -> T.Type -> T.Type -> RightDocs
11031103badOpRightFallback localizer category op tipe expected =
11041104 EmphRight
11051105 ( D.reflow $
1106− "The right argument of (" <> N.toString op <> ") is causing problems."
1106+ "The right argument of (" <> Name.toString op <> ") is causing problems."
11071107 , typeComparison localizer tipe expected
11081108 (addCategory "The right argument is" category)
1109− ("But (" <> N.toString op <> ") needs the right argument to be:")
1109+ ("But (" <> Name.toString op <> ") needs the right argument to be:")
11101110 [ D.toSimpleHint $
1111− "With operators like (" ++ N.toString op ++ ") I always check the left\
1111+ "With operators like (" ++ Name.toString 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 ]
@@ -1314,11 +1314,11 @@ badAppendRight localizer category tipe expected =
13141314data ThisThenThat = FloatInt | IntFloat
13151315
13161316
1317−badCast :: N.Name -> ThisThenThat -> RightDocs
1317+badCast :: Name.Name -> ThisThenThat -> RightDocs
13181318badCast op thisThenThat =
13191319 EmphBoth
13201320 ( D.reflow $
1321− "I need both sides of (" <> N.toString op <> ") to be the exact same type. Both Int or both Float."
1321+ "I need both sides of (" <> Name.toString 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"]
@@ -1571,13 +1571,13 @@ badEquality localizer op tipe expected =
15711571-- INFINITE TYPES
15721572
15731573
1574−toInfiniteReport :: Code.Source -> L.Localizer -> R.Region -> N.Name -> T.Type -> Report.Report
1574+toInfiniteReport :: Code.Source -> L.Localizer -> R.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 " <> N.toString name <> ":"
1580+ "I am inferring a weird self-referential type for " <> Name.toString name <> ":"
15811581 ,
15821582 D.stack
15831583 [ D.reflow $
compiler/src/Reporting/Render/Type.hs+3−3
@@ -15,10 +15,10 @@ module Reporting.Render.Type
1515
1616
1717import qualified Data.Maybe as Maybe
18+import qualified Data.Name as Name
1819
1920import qualified AST.Source as Src
2021import qualified AST.Canonical as Can
21−import qualified Elm.Name as N
2222import qualified Reporting.Annotation as A
2323import qualified Reporting.Doc as D
2424import Reporting.Doc ( Doc, (<+>), (<>) )
@@ -173,7 +173,7 @@ srcToDoc context (A.At _ tipe) =
173173 (map (srcToDoc None) cs)
174174
175175
176−srcFieldToDocs :: (A.Located N.Name, Src.Type) -> (Doc, Doc)
176+srcFieldToDocs :: (A.Located Name.Name, Src.Type) -> (Doc, Doc)
177177srcFieldToDocs (A.At _ fieldName, fieldType) =
178178 ( D.fromName fieldName
179179 , srcToDoc None fieldType
@@ -237,7 +237,7 @@ canToDoc localizer context tipe =
237237 (map (canToDoc localizer App . snd) args)
238238
239239
240−canFieldToDoc :: L.Localizer -> (N.Name, Can.Type) -> (Doc, Doc)
240+canFieldToDoc :: L.Localizer -> (Name.Name, Can.Type) -> (Doc, Doc)
241241canFieldToDoc localizer (name, tipe) =
242242 ( D.fromName name
243243 , canToDoc localizer None tipe
compiler/src/Reporting/Render/Type/Localizer.hs+16−16
@@ -14,13 +14,13 @@ module Reporting.Render.Type.Localizer
1414
1515
1616import qualified Data.Map as Map
17+import qualified Data.Name as Name
1718import qualified Data.Set as Set
1819
1920import qualified AST.Source as Src
2021import qualified AST.Module.Name as ModuleName
2122import qualified AST.Valid as Valid
2223import qualified Elm.Compiler.Imports as Imports
23−import qualified Elm.Name as N
2424import qualified Elm.Package as Pkg
2525import Reporting.Doc ((<>))
2626import qualified Reporting.Doc as D
@@ -32,19 +32,19 @@ import qualified Reporting.Annotation as A
3232
3333
3434newtype Localizer =
35− Localizer (Map.Map N.Name Import)
35+ Localizer (Map.Map Name.Name Import)
3636
3737
3838data Import =
3939 Import
40− { _alias :: Maybe N.Name
40+ { _alias :: Maybe Name.Name
4141 , _exposing :: Exposing
4242 }
4343
4444
4545data Exposing
4646 = All
47− | Only (Set.Set N.Name)
47+ | Only (Set.Set Name.Name)
4848
4949
5050empty :: Localizer
@@ -56,36 +56,36 @@ empty =
5656-- LOCALIZE
5757
5858
59−toDoc :: Localizer -> ModuleName.Canonical -> N.Name -> D.Doc
59+toDoc :: Localizer -> ModuleName.Canonical -> Name.Name -> D.Doc
6060toDoc localizer home name =
6161 D.fromString (toString localizer home name)
6262
6363
64−toString :: Localizer -> ModuleName.Canonical -> N.Name -> String
64+toString :: Localizer -> ModuleName.Canonical -> Name.Name -> String
6565toString (Localizer localizer) moduleName@(ModuleName.Canonical _ home) name =
6666 case Map.lookup home localizer of
6767 Nothing ->
68− N.toString home <> "." <> N.toString name
68+ Name.toString home <> "." <> Name.toString name
6969
7070 Just (Import alias exposing) ->
7171 case exposing of
7272 All ->
73− N.toString name
73+ Name.toString name
7474
7575 Only set ->
7676 if Set.member name set then
77− N.toString name
78− else if name == N.list && moduleName == ModuleName.list then
77+ Name.toString name
78+ else if name == Name.list && moduleName == ModuleName.list then
7979 "List"
8080 else
81− N.toString (maybe home id alias) <> "." <> N.toString name
81+ Name.toString (maybe home id alias) <> "." <> Name.toString name
8282
8383
8484
8585-- FROM NAMES
8686
8787
88−fromNames :: Map.Map N.Name a -> Localizer
88+fromNames :: Map.Map Name.Name a -> Localizer
8989fromNames names =
9090 Localizer $ Map.map (\_ -> Import Nothing All) names
9191
@@ -100,7 +100,7 @@ fromModule (Valid.Module name _ _ _ imports _ _ _ _ _) =
100100 (name, Import Nothing All) : map toPair imports
101101
102102
103−toPair :: Src.Import -> (N.Name, Import)
103+toPair :: Src.Import -> (Name.Name, Import)
104104toPair (Src.Import (A.At _ name) alias exposing) =
105105 ( name
106106 , Import alias (toExposing exposing)
@@ -117,7 +117,7 @@ toExposing exposing =
117117 Only (foldr addType Set.empty exposedList)
118118
119119
120−addType :: A.Located Src.Exposed -> Set.Set N.Name -> Set.Set N.Name
120+addType :: A.Located Src.Exposed -> Set.Set Name.Name -> Set.Set Name.Name
121121addType (A.At _ exposed) types =
122122 case exposed of
123123 Src.Lower _ -> types
@@ -132,11 +132,11 @@ addType (A.At _ exposed) types =
132132replEmpty :: Localizer
133133replEmpty =
134134 Localizer $
135− Map.insert N.replModule (Import Nothing All) $
135+ Map.insert Name.replModule (Import Nothing All) $
136136 Map.fromList $ map toPair $ Imports.addDefaults Pkg.dummyName []
137137
138138
139−replAdd :: N.Name -> Maybe N.Name -> Src.Exposing -> Localizer -> Localizer
139+replAdd :: Name.Name -> Maybe Name.Name -> Src.Exposing -> Localizer -> Localizer
140140replAdd name alias exposing (Localizer localizer) =
141141 Localizer $ Map.insert name (Import alias (toExposing exposing)) localizer
142142
compiler/src/Reporting/Warning.hs+10−10
@@ -9,10 +9,10 @@ module Reporting.Warning
99
1010
1111import Data.Monoid ((<>))
12+import qualified Data.Name as Name
1213
1314import qualified AST.Canonical as Can
1415import qualified AST.Utils.Type as Type
15−import qualified Elm.Name as N
1616import qualified Reporting.Doc as D
1717import qualified Reporting.Region as R
1818import qualified Reporting.Report as Report
@@ -26,9 +26,9 @@ import qualified Reporting.Render.Type.Localizer as L
2626
2727
2828data Warning
29− = UnusedImport R.Region N.Name
30− | UnusedVariable R.Region Context N.Name
31− | MissingTypeAnnotation R.Region N.Name Can.Type
29+ = UnusedImport R.Region Name.Name
30+ | UnusedVariable R.Region Context Name.Name
31+ | MissingTypeAnnotation R.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 `" <> N.toString moduleName <> "` module is used in this file."
49+ "Nothing from the `" <> Name.toString 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 `" <> N.toString name <> "` anywhere."
60+ "You are not using `" <> Name.toString name <> "` anywhere."
6161 ,
6262 D.stack
6363 [ D.reflow $
64− "Is there a typo? Maybe you intended to use `" <> N.toString name
64+ "Is there a typo? Maybe you intended to use `" <> Name.toString 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 `" <> N.toString name
71+ ( "If you are sure there is no typo, replace `" <> Name.toString 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 `" <> N.toString name <> "` function has no type annotation."
84+ "The `" <> Name.toString name <> "` function has no type annotation."
8585
8686 _ ->
87− "The `" <> N.toString name <> "` definition has no type annotation."
87+ "The `" <> Name.toString 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:"