on master help sign in
Switch Reporting/ over to Data.Name
2fb73b7Evan Czaplicki
compiler/src/Reporting/Doc.hs+11−5
@@ -8,7 +8,7 @@ module Reporting.Doc
8 , P.red, P.cyan, P.magenta, P.green, P.blue, P.black, P.yellow
8 , P.red, P.cyan, P.magenta, P.green, P.blue, P.black, P.yellow
9 , P.dullred, P.dullcyan, P.dullyellow
9 , P.dullred, P.dullcyan, P.dullyellow
10
10
11− , fromString, fromText, fromName, fromInt
11+ , fromString, fromText, fromName, fromInt, fromUtf8
12 , toAnsi, toString, toLine
12 , toAnsi, toString, toLine
13 , encode
13 , encode
14
14
@@ -25,10 +25,11 @@ module Reporting.Doc
25import Prelude hiding (cycle)
25import Prelude hiding (cycle)
26import qualified Data.List as List
26import qualified Data.List as List
27import Data.Monoid ((<>))
27import Data.Monoid ((<>))
28+import qualified Data.Name as Name
28import qualified Data.Text as Text
29import qualified Data.Text as Text
29import qualified Data.Text.Lazy as TL
30import qualified Data.Text.Lazy as TL
30import qualified Data.Text.Lazy.Builder as TB
31import qualified Data.Text.Lazy.Builder as TB
31−import qualified Elm.Name as N
32+import qualified Data.Utf8 as Utf8
32import qualified System.Console.ANSI.Types as Ansi
33import qualified System.Console.ANSI.Types as Ansi
33import System.IO (Handle)
34import System.IO (Handle)
34import qualified Text.PrettyPrint.ANSI.Leijen as P
35import qualified Text.PrettyPrint.ANSI.Leijen as P
@@ -53,9 +54,9 @@ fromText txt =
53 P.text (Text.unpack txt)
54 P.text (Text.unpack txt)
54
55
55
56
56−fromName :: N.Name -> P.Doc
57+fromName :: Name.Name -> P.Doc
57fromName name =
58fromName name =
58− P.text (N.toString name)
59+ P.text (Name.toString name)
59
60
60
61
61fromInt :: Int -> P.Doc
62fromInt :: Int -> P.Doc
@@ -63,6 +64,11 @@ fromInt n =
63 P.text (show n)
64 P.text (show n)
64
65
65
66
67+fromUtf8 :: Utf8.Utf8 -> P.Doc
68+fromUtf8 utf8 =
69+ P.text (Utf8.toString utf8)
70+
71+
66
72
67-- TO STRING
73-- TO STRING
68
74
@@ -208,7 +214,7 @@ intToOrdinal number =
208
214
209
215
210
216
211−cycle :: Int -> [N.Name] -> P.Doc
217+cycle :: Int -> [Name.Name] -> P.Doc
212cycle indent names =
218cycle indent names =
213 let
219 let
214 topLine = "┌─────┐"
220 topLine = "┌─────┐"
compiler/src/Reporting/Error/Canonicalize.hs+121−121
@@ -15,13 +15,13 @@ module Reporting.Error.Canonicalize
15
15
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
19
20
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
37
37
38
38
39data Error
39data Error
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)]
78
78
79
79
80data BadArityContext
80data BadArityContext
@@ -84,7 +84,7 @@ data BadArityContext
84
84
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
98
98
99
99
100data PortProblem
100data PortProblem
@@ -107,8 +107,8 @@ data PortProblem
107
107
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)
112 }
112 }
113
113
114
114
@@ -123,7 +123,7 @@ data VarKind
123 | BadType
123 | BadType
124
124
125
125
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
129 BadOp ->
129 BadOp ->
@@ -155,7 +155,7 @@ toReport source err =
155 Report.toCodeSnippet source region Nothing
155 Report.toCodeSnippet source region Nothing
156 (
156 (
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 <> ":"
161 ,
161 ,
@@ -189,7 +189,7 @@ toReport source err =
189 Report.toCodeSnippet source region Nothing
189 Report.toCodeSnippet source region Nothing
190 (
190 (
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:"
194 ,
194 ,
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
202 (
202 (
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:"
206 ,
206 ,
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
216 (
216 (
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."
219 ,
219 ,
220 D.reflow
220 D.reflow
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 =
223
223
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."
227
227
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."
231
231
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."
235
235
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."
239
239
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."
243
243
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."
247
247
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."
251
251
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."
257
257
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."
260
260
261 DPCaseBranch ->
261 DPCaseBranch ->
262− "This `case` pattern has multiple `" <> N.toString name <> "` variables."
262+ "This `case` pattern has multiple `" <> Name.toString name <> "` variables."
263
263
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!"
266
266
267 DPDestruct ->
267 DPDestruct ->
268− "This pattern contains multiple `" <> N.toString name <> "` variables."
268+ "This pattern contains multiple `" <> Name.toString name <> "` variables."
269
269
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
273 (
273 (
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:"
276 ,
276 ,
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!"
279 )
279 )
280
280
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
284 (
284 (
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."
287 ,
287 ,
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!"
290 )
290 )
291
291
292
292
293 ExportDuplicate name r1 r2 ->
293 ExportDuplicate name r1 r2 ->
294 let
294 let
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!"
297 in
297 in
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 ->
314 let
314 let
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
318 in
318 in
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 =
344 (
344 (
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."
348 ,
348 ,
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
356 (
356 (
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:"
360 ,
360 ,
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
376 (
376 (
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!"
379 ,
379 ,
380 mempty
380 mempty
381 )
381 )
@@ -385,7 +385,7 @@ toReport source err =
385 Report.toCodeSnippet source region Nothing
385 Report.toCodeSnippet source region Nothing
386 (
386 (
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:"
389 ,
389 ,
390 D.stack
390 D.stack
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 ->
400 let
400 let
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
404 in
404 in
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
407 (
407 (
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 <> "`:"
412 ,
412 ,
413 case map D.fromString suggestions of
413 case map D.fromString suggestions of
414 [] ->
414 [] ->
@@ -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."
458 ]
458 ]
459 )
459 )
460
460
@@ -491,8 +491,8 @@ toReport source err =
491 else
491 else
492 let
492 let
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)
496
496
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
502 (
502 (
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."
505 ,
505 ,
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
520 (
520 (
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:"
524 ,
524 ,
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
534 (
534 (
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 <> ":"
537 ,
537 ,
538 D.stack
538 D.stack
539 [ elaboration
539 [ elaboration
@@ -570,14 +570,14 @@ toReport source err =
570 "an unspecified type"
570 "an unspecified type"
571 ,
571 ,
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."
576 )
576 )
577
577
578 UnsupportedType name ->
578 UnsupportedType name ->
579 (
579 (
580− "a `" <> N.toString name <> "` value"
580+ "a `" <> Name.toString name <> "` value"
581 ,
581 ,
582 D.stack
582 D.stack
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 ->
613 (
613 (
614− "The `" <> N.toString name <> "` port cannot be just a command."
614+ "The `" <> Name.toString name <> "` port cannot be just a command."
615 ,
615 ,
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 =
620
620
621 CmdExtraArgs n ->
621 CmdExtraArgs n ->
622 (
622 (
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."
624 ,
624 ,
625 let
625 let
626 theseItemsInSomething
626 theseItemsInSomething
@@ -634,7 +634,7 @@ toReport source err =
634
634
635 CmdBadMsg ->
635 CmdBadMsg ->
636 (
636 (
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."
638 ,
638 ,
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 =
643 )
643 )
644
644
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."
647 ,
647 ,
648 D.stack
648 D.stack
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 =
659
659
660 NotCmdOrSub ->
660 NotCmdOrSub ->
661 (
661 (
662− "I am confused about the `" <> N.toString name <> "` port declaration."
662+ "I am confused about the `" <> Name.toString name <> "` port declaration."
663 ,
663 ,
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 =
693 [] ->
693 [] ->
694 (
694 (
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."
697 ,
697 ,
698 D.stack
698 D.stack
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 =
714 names ->
714 names ->
715 (
715 (
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."
718 ,
718 ,
719 D.stack
719 D.stack
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 =
739 in
739 in
740 (
740 (
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."
743 ,
743 ,
744 D.stack
744 D.stack
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 =
764 ,
764 ,
765 D.stack
765 D.stack
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:"
781 , advice
781 , advice
782 )
782 )
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:"
785 , advice
785 , advice
786 )
786 )
@@ -902,7 +902,7 @@ toReport source err =
902 Report.toCodeSnippet source aliasRegion Nothing
902 Report.toCodeSnippet source aliasRegion Nothing
903 (
903 (
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."
906 ,
906 ,
907 D.stack
907 D.stack
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
922
922
923
923
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 =
926 let
926 let
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."
966 ]
966 ]
@@ -993,7 +993,7 @@ nameClash source r1 r2 messageThatEndsWithPunctuation =
993-- AMBIGUOUS NAME
993-- AMBIGUOUS NAME
994
994
995
995
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"
1008 in
1008 in
1009 (
1009 (
1010− D.reflow $ "This usage of `" ++ N.toString name ++ "` is ambiguous."
1010+ D.reflow $ "This usage of `" ++ Name.toString name ++ "` is ambiguous."
1011 ,
1011 ,
1012 D.stack
1012 D.stack
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."
1018 ]
1018 ]
@@ -1046,18 +1046,18 @@ ambiguousName source region maybePrefix name possibleHomes thing =
1046-- NOT FOUND
1046-- NOT FOUND
1047
1047
1048
1048
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) =
1051 let
1051 let
1052 givenName =
1052 givenName =
1053− maybe N.toString toQualString maybePrefix name
1053+ maybe Name.toString toQualString maybePrefix name
1054
1054
1055 possibleNames =
1055 possibleNames =
1056 let
1056 let
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
1059 in
1059 in
1060− Map.foldrWithKey addQuals (map N.toString (Set.toList locals)) quals
1060+ Map.foldrWithKey addQuals (map Name.toString (Set.toList locals)) quals
1061
1061
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:")
1099
1099
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:")
1104 )
1104 )
1105
1105
1106
1106
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
1110
1110
1111
1111
1112
1112
@@ -1200,7 +1200,7 @@ modHint =
1200-- ARG MISMATCH
1200-- ARG MISMATCH
1201
1201
1202
1202
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 =
1205 let
1205 let
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
1213 (
1213 (
1214 D.reflow $
1214 D.reflow $
1215− kind <> " " <> N.toString name <> " has " <> numArgs <> "."
1215+ kind <> " " <> Name.toString name <> " has " <> numArgs <> "."
1216 ,
1216 ,
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
1224
1224
1225
1225
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
1229 [] ->
1229 [] ->
@@ -1262,7 +1262,7 @@ aliasRecursionReport source region name args tipe others =
1262 )
1262 )
1263
1263
1264
1264
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 =
1267 D.vcat
1267 D.vcat
1268 [ D.dullyellow $
1268 [ D.dullyellow $
compiler/src/Reporting/Error/Docs.hs+15−14
@@ -7,7 +7,8 @@ module Reporting.Error.Docs
7 where
7 where
8
8
9
9
10−import qualified Elm.Name as N
10+import qualified Data.Name as Name
11+
11import Reporting.Doc ((<>))
12import Reporting.Doc ((<>))
12import qualified Reporting.Doc as D
13import qualified Reporting.Doc as D
13import qualified Reporting.Region as R
14import qualified Reporting.Region as R
@@ -19,11 +20,11 @@ import qualified Reporting.Report as Report
19data Error
20data Error
20 = NoDocs R.Region
21 = NoDocs R.Region
21 | ImplicitExposing R.Region
22 | ImplicitExposing R.Region
22− | Duplicate N.Name R.Region R.Region
23+ | Duplicate Name.Name R.Region R.Region
23− | OnlyInDocs N.Name R.Region
24+ | OnlyInDocs Name.Name R.Region
24− | OnlyInExports N.Name R.Region
25+ | OnlyInExports Name.Name R.Region
25− | NoComment N.Name R.Region
26+ | NoComment Name.Name R.Region
26− | NoAnnotation N.Name R.Region
27+ | NoAnnotation Name.Name R.Region
27
28
28
29
29
30
@@ -65,14 +66,14 @@ toReport source err =
65 Report.toCodePair source r1 r2
66 Report.toCodePair source r1 r2
66 (
67 (
67 D.reflow $
68 D.reflow $
68− "There can only be one `" <> N.toString name
69+ "There can only be one `" <> Name.toString name
69 <> "` in your module documentation, but it is listed twice:"
70 <> "` in your module documentation, but it is listed twice:"
70 ,
71 ,
71 "Remove one of them!"
72 "Remove one of them!"
72 )
73 )
73 (
74 (
74 D.reflow $
75 D.reflow $
75− "There can only be one `" <> N.toString name
76+ "There can only be one `" <> Name.toString name
76 <> "` in your module documentation, but I see two. One here:"
77 <> "` in your module documentation, but I see two. One here:"
77 ,
78 ,
78 "And another one over here:"
79 "And another one over here:"
@@ -85,12 +86,12 @@ toReport source err =
85 Report.toCodeSnippet source region Nothing
86 Report.toCodeSnippet source region Nothing
86 (
87 (
87 D.reflow $
88 D.reflow $
88− "I do not see `" <> N.toString name
89+ "I do not see `" <> Name.toString name
89 <> "` in the `exposing` list, but it is in your module documentation:"
90 <> "` in the `exposing` list, but it is in your module documentation:"
90 ,
91 ,
91 D.reflow $
92 D.reflow $
92 "Does it need to be added to the `exposing` list as well? Or maybe you removed `"
93 "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?"
94 )
95 )
95
96
96 OnlyInExports name region ->
97 OnlyInExports name region ->
@@ -98,12 +99,12 @@ toReport source err =
98 Report.toCodeSnippet source region Nothing
99 Report.toCodeSnippet source region Nothing
99 (
100 (
100 D.reflow $
101 D.reflow $
101− "I do not see `" <> N.toString name
102+ "I do not see `" <> Name.toString name
102 <> "` in your module documentation, but it is in your `exposing` list:"
103 <> "` in your module documentation, but it is in your `exposing` list:"
103 ,
104 ,
104 D.stack
105 D.stack
105 [ D.reflow $
106 [ D.reflow $
106− "Add a line like `@docs " <> N.toString name
107+ "Add a line like `@docs " <> Name.toString name
107 <> "` to your module documentation!"
108 <> "` to your module documentation!"
108 , D.link "Note" "See" "docs" "for more guidance on writing high quality docs."
109 , D.link "Note" "See" "docs" "for more guidance on writing high quality docs."
109 ]
110 ]
@@ -114,7 +115,7 @@ toReport source err =
114 Report.toCodeSnippet source region Nothing
115 Report.toCodeSnippet source region Nothing
115 (
116 (
116 D.reflow $
117 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."
118 ,
119 ,
119 D.stack
120 D.stack
120 [ D.reflow $
121 [ D.reflow $
@@ -128,7 +129,7 @@ toReport source err =
128 Report.toCodeSnippet source region Nothing
129 Report.toCodeSnippet source region Nothing
129 (
130 (
130 D.reflow $
131 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."
132 ,
133 ,
133 D.stack
134 D.stack
134 [ D.reflow $
135 [ D.reflow $
compiler/src/Reporting/Error/Main.hs+5−4
@@ -7,8 +7,9 @@ module Reporting.Error.Main
7 where
7 where
8
8
9
9
10+import qualified Data.Name as Name
11+
10import qualified AST.Canonical as Can
12import qualified AST.Canonical as Can
11−import qualified Elm.Name as N
12import qualified Reporting.Doc as D
13import qualified Reporting.Doc as D
13import qualified Reporting.Error.Canonicalize as E
14import qualified Reporting.Error.Canonicalize as E
14import qualified Reporting.Region as R
15import qualified Reporting.Region as R
@@ -24,7 +25,7 @@ import qualified Reporting.Report as Report
24
25
25data Error
26data Error
26 = BadType R.Region Can.Type
27 = BadType R.Region Can.Type
27− | BadCycle R.Region [N.Name]
28+ | BadCycle R.Region [Name.Name]
28 | BadFlags R.Region Can.Type E.InvalidPayload
29 | BadFlags R.Region Can.Type E.InvalidPayload
29
30
30
31
@@ -100,14 +101,14 @@ toReport localizer source err =
100 "an unspecified type"
101 "an unspecified type"
101 ,
102 ,
102 D.reflow $
103 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.\
104 \ I need to know exactly what type of data I am getting, so I can guarantee that\
105 \ I need to know exactly what type of data I am getting, so I can guarantee that\
105 \ unexpected data cannot sneak in and crash the Elm program."
106 \ unexpected data cannot sneak in and crash the Elm program."
106 )
107 )
107
108
108 E.UnsupportedType name ->
109 E.UnsupportedType name ->
109 (
110 (
110− "a `" ++ N.toString name ++ "` value"
111+ "a `" ++ Name.toString name ++ "` value"
111 ,
112 ,
112 D.stack
113 D.stack
113 [ D.reflow $ "I cannot handle that. The types that CAN be in flags include:"
114 [ 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 =
117 NonList (P.Literal literal) ->
117 NonList (P.Literal literal) ->
118 case literal of
118 case literal of
119 P.Chr chr ->
119 P.Chr chr ->
120− D.fromText ("'" <> chr <> "'")
120+ "'" <> D.fromUtf8 chr <> "'"
121
121
122 P.Str str ->
122 P.Str str ->
123− D.fromText ("\"" <> str <> "\"")
123+ "\"" <> D.fromUtf8 str <> "\""
124
124
125 P.Int int ->
125 P.Int int ->
126 D.fromInt int
126 D.fromInt int
compiler/src/Reporting/Error/Syntax.hs+20−20
@@ -13,10 +13,10 @@ module Reporting.Error.Syntax
13
13
14
14
15import Data.Monoid ((<>))
15import Data.Monoid ((<>))
16+import qualified Data.Name as Name
16import qualified Data.Set as Set
17import qualified Data.Set as Set
17import qualified Data.Text as Text
18import qualified Data.Text as Text
18
19
19−import qualified Elm.Name as N
20import qualified Reporting.Doc as D
20import qualified Reporting.Doc as D
21import qualified Reporting.Region as R
21import qualified Reporting.Region as R
22import qualified Reporting.Render.Code as Code
22import qualified Reporting.Render.Code as Code
@@ -29,9 +29,9 @@ import qualified Reporting.Report as Report
29
29
30data Error
30data Error
31 = CommentOnNothing R.Region
31 = CommentOnNothing R.Region
32− | UnexpectedPort R.Region N.Name
32+ | UnexpectedPort R.Region Name.Name
33− | TypeWithBadDefinition R.Region N.Name N.Name
33+ | TypeWithBadDefinition R.Region Name.Name Name.Name
34− | TypeWithoutDefinition R.Region N.Name
34+ | TypeWithoutDefinition R.Region Name.Name
35 | Parse R.Region (Maybe R.Region) Problem
35 | Parse R.Region (Maybe R.Region) Problem
36
36
37
37
@@ -90,7 +90,7 @@ data Theory
90data Next
90data Next
91 = Decl
91 = Decl
92 | Expr
92 | Expr
93− | AfterOpExpr N.Name
93+ | AfterOpExpr Name.Name
94 | ElseBranch
94 | ElseBranch
95 | Arg
95 | Arg
96 | Pattern
96 | Pattern
@@ -112,8 +112,8 @@ data Context
112 | ExprTuple
112 | ExprTuple
113 | ExprRecord
113 | ExprRecord
114 ----------------
114 ----------------
115− | Definition N.Name
115+ | Definition Name.Name
116− | Annotation N.Name
116+ | Annotation Name.Name
117 ----------------
117 ----------------
118 | TypeTuple
118 | TypeTuple
119 | TypeRecord
119 | TypeRecord
@@ -155,7 +155,7 @@ toReport source err =
155 Report.toCodeSnippet source region Nothing
155 Report.toCodeSnippet source region Nothing
156 (
156 (
157 D.reflow $
157 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."
159 ,
159 ,
160 D.stack
160 D.stack
161 [ "It needs to be in a `port` module."
161 [ "It needs to be in a `port` module."
@@ -171,9 +171,9 @@ toReport source err =
171 Report.toCodeSnippet source region Nothing
171 Report.toCodeSnippet source region Nothing
172 (
172 (
173 D.reflow $
173 D.reflow $
174− "I see a `" <> N.toString annName
174+ "I see a `" <> Name.toString annName
175 <> "` annotation, but it is followed by a `"
175 <> "` annotation, but it is followed by a `"
176− <> N.toString defName <> "` definition."
176+ <> Name.toString defName <> "` definition."
177 ,
177 ,
178 D.fillSep
178 D.fillSep
179 ["The","annotation","and","definition","names","must","match!"
179 ["The","annotation","and","definition","names","must","match!"
@@ -189,7 +189,7 @@ toReport source err =
189 Report.toCodeSnippet source region Nothing
189 Report.toCodeSnippet source region Nothing
190 (
190 (
191 D.reflow $
191 D.reflow $
192− "There is a type annotation for `" <> N.toString name
192+ "There is a type annotation for `" <> Name.toString name
193 <> "` but there is no corresponding definition!"
193 <> "` but there is no corresponding definition!"
194 ,
194 ,
195 "Directly below the type annotation, put a definition like:\n\n"
195 "Directly below the type annotation, put a definition like:\n\n"
@@ -597,8 +597,8 @@ contextToString defaultString prefixString stack =
597 ExprList -> "a list" <> anchor
597 ExprList -> "a list" <> anchor
598 ExprTuple -> "an expression (in parentheses)" <> anchor
598 ExprTuple -> "an expression (in parentheses)" <> anchor
599 ExprRecord -> "a record" <> anchor
599 ExprRecord -> "a record" <> anchor
600− Definition name -> N.toString name <> "'s definition"
600+ Definition name -> Name.toString name <> "'s definition"
601− Annotation name -> N.toString name <> "'s type annotation"
601+ Annotation name -> Name.toString name <> "'s type annotation"
602 TypeTuple -> "a type (in parentheses)" <> anchor
602 TypeTuple -> "a type (in parentheses)" <> anchor
603 TypeRecord -> "a record type" <> anchor
603 TypeRecord -> "a record type" <> anchor
604 PatternList -> "a list pattern" <> anchor
604 PatternList -> "a list pattern" <> anchor
@@ -621,10 +621,10 @@ getAnchor stack =
621 (context, _) : rest ->
621 (context, _) : rest ->
622 case context of
622 case context of
623 Definition name ->
623 Definition name ->
624− " in " <> N.toString name <> "'s definition"
624+ " in " <> Name.toString name <> "'s definition"
625
625
626 Annotation name ->
626 Annotation name ->
627− " in " <> N.toString name <> "'s type annotation"
627+ " in " <> Name.toString name <> "'s type annotation"
628
628
629 _ ->
629 _ ->
630 getAnchor rest
630 getAnchor rest
@@ -692,7 +692,7 @@ theoryToString context theory =
692 case next of
692 case next of
693 Decl -> "a declaration, like `x = 5` or `type alias Model = { ... }`"
693 Decl -> "a declaration, like `x = 5` or `type alias Model = { ... }`"
694 Expr -> "an expression, like x or 42"
694 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"
696 ElseBranch -> "an `else` branch. An `if` must handle both possibilities."
696 ElseBranch -> "an `else` branch. An `if` must handle both possibilities."
697 Arg -> "an argument, like `name` or `total`"
697 Arg -> "an argument, like `name` or `total`"
698 Pattern -> "a pattern, like `name` or (Just x)"
698 Pattern -> "a pattern, like `name` or (Just x)"
@@ -710,7 +710,7 @@ equalsTheory stack =
710 (context, _) : rest ->
710 (context, _) : rest ->
711 case context of
711 case context of
712 ExprRecord -> "an equals sign (=) followed by an expression"
712 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"
714 TypeUnion -> "an equals sign (=) followed by the first union type constructor"
714 TypeUnion -> "an equals sign (=) followed by the first union type constructor"
715 TypeAlias -> "an equals sign (=) followed by the aliased type"
715 TypeAlias -> "an equals sign (=) followed by the aliased type"
716 _ -> equalsTheory rest
716 _ -> equalsTheory rest
@@ -745,8 +745,8 @@ badSpace stack =
745 ExprList -> "the end of that list" <> badSpaceExprEnd rest
745 ExprList -> "the end of that list" <> badSpaceExprEnd rest
746 ExprTuple -> "a closing paren" <> badSpaceExprEnd rest
746 ExprTuple -> "a closing paren" <> badSpaceExprEnd rest
747 ExprRecord -> "the end of that record" <> badSpaceExprEnd rest
747 ExprRecord -> "the end of that record" <> badSpaceExprEnd rest
748− Definition name -> "the rest of " <> N.toString name <> "'s definition" <> badSpaceExprEnd stack
748+ Definition name -> "the rest of " <> Name.toString name <> "'s definition" <> badSpaceExprEnd stack
749− Annotation name -> "the rest of " <> N.toString name <> "'s type annotation" <> badSpaceEnd
749+ Annotation name -> "the rest of " <> Name.toString name <> "'s type annotation" <> badSpaceEnd
750 TypeTuple -> "a closing paren" <> badSpaceEnd
750 TypeTuple -> "a closing paren" <> badSpaceEnd
751 TypeRecord -> "the end of that record" <> badSpaceEnd
751 TypeRecord -> "the end of that record" <> badSpaceEnd
752 PatternList -> "the end of that list" <> badSpaceEnd
752 PatternList -> "the end of that list" <> badSpaceEnd
@@ -780,7 +780,7 @@ badSpaceExprEnd stack =
780 "more indentation? (Try " <> show (column + 1) <> "+ spaces.)"
780 "more indentation? (Try " <> show (column + 1) <> "+ spaces.)"
781 in
781 in
782 ". Maybe you forgot some code? Or maybe the body of `"
782 ". Maybe you forgot some code? Or maybe the body of `"
783− <> N.toString name
783+ <> Name.toString name
784 <> "` needs " <> ending
784 <> "` needs " <> ending
785
785
786 _ : rest ->
786 _ : rest ->
compiler/src/Reporting/Error/Type.hs+73−73
@@ -22,10 +22,10 @@ module Reporting.Error.Type
22import Prelude hiding (round)
22import Prelude hiding (round)
23import qualified Data.Map as Map
23import qualified Data.Map as Map
24import Data.Monoid ((<>))
24import Data.Monoid ((<>))
25+import qualified Data.Name as Name
25
26
26import qualified AST.Canonical as Can
27import qualified AST.Canonical as Can
27import qualified Data.Index as Index
28import qualified Data.Index as Index
28−import qualified Elm.Name as N
29import qualified Reporting.Doc as D
29import qualified Reporting.Doc as D
30import qualified Reporting.Region as R
30import qualified Reporting.Region as R
31import qualified Reporting.Render.Code as Code
31import qualified Reporting.Render.Code as Code
@@ -43,7 +43,7 @@ import qualified Type.Error as T
43data Error
43data Error
44 = BadExpr R.Region Category T.Type (Expected T.Type)
44 = BadExpr R.Region Category T.Type (Expected T.Type)
45 | BadPattern R.Region PCategory T.Type (PExpected T.Type)
45 | 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
47
47
48
48
49
49
@@ -53,22 +53,22 @@ data Error
53data Expected tipe
53data Expected tipe
54 = NoExpectation tipe
54 = NoExpectation tipe
55 | FromContext R.Region Context tipe
55 | FromContext R.Region Context tipe
56− | FromAnnotation N.Name Int SubContext tipe
56+ | FromAnnotation Name.Name Int SubContext tipe
57
57
58
58
59data Context
59data Context
60 = ListEntry Index.ZeroBased
60 = ListEntry Index.ZeroBased
61 | Negate
61 | Negate
62− | OpLeft N.Name
62+ | OpLeft Name.Name
63− | OpRight N.Name
63+ | OpRight Name.Name
64 | IfCondition
64 | IfCondition
65 | IfBranch Index.ZeroBased
65 | IfBranch Index.ZeroBased
66 | CaseBranch Index.ZeroBased
66 | CaseBranch Index.ZeroBased
67 | CallArity MaybeName Int
67 | CallArity MaybeName Int
68 | CallArg MaybeName Index.ZeroBased
68 | CallArg MaybeName Index.ZeroBased
69− | RecordAccess R.Region (Maybe N.Name) R.Region N.Name
69+ | RecordAccess R.Region (Maybe Name.Name) R.Region Name.Name
70− | RecordUpdateKeys N.Name (Map.Map N.Name Can.FieldUpdate)
70+ | RecordUpdateKeys Name.Name (Map.Map Name.Name Can.FieldUpdate)
71− | RecordUpdateValue N.Name
71+ | RecordUpdateValue Name.Name
72 | Destructure
72 | Destructure
73
73
74
74
@@ -79,9 +79,9 @@ data SubContext
79
79
80
80
81data MaybeName
81data MaybeName
82− = FuncName N.Name
82+ = FuncName Name.Name
83− | CtorName N.Name
83+ | CtorName Name.Name
84− | OpName N.Name
84+ | OpName Name.Name
85 | NoName
85 | NoName
86
86
87
87
@@ -95,15 +95,15 @@ data Category
95 | Case
95 | Case
96 | CallResult MaybeName
96 | CallResult MaybeName
97 | Lambda
97 | Lambda
98− | Accessor N.Name
98+ | Accessor Name.Name
99− | Access N.Name
99+ | Access Name.Name
100 | Record
100 | Record
101 | Tuple
101 | Tuple
102 | Unit
102 | Unit
103 | Shader
103 | Shader
104 | Effects
104 | Effects
105− | Local N.Name
105+ | Local Name.Name
106− | Foreign N.Name
106+ | Foreign Name.Name
107
107
108
108
109
109
@@ -116,9 +116,9 @@ data PExpected tipe
116
116
117
117
118data PContext
118data PContext
119− = PTypedArg N.Name Index.ZeroBased
119+ = PTypedArg Name.Name Index.ZeroBased
120 | PCaseMatch Index.ZeroBased
120 | PCaseMatch Index.ZeroBased
121− | PCtorArg N.Name Index.ZeroBased
121+ | PCtorArg Name.Name Index.ZeroBased
122 | PListEntry Index.ZeroBased
122 | PListEntry Index.ZeroBased
123 | PTail
123 | PTail
124
124
@@ -128,7 +128,7 @@ data PCategory
128 | PUnit
128 | PUnit
129 | PTuple
129 | PTuple
130 | PList
130 | PList
131− | PCtor N.Name
131+ | PCtor Name.Name
132 | PInt
132 | PInt
133 | PStr
133 | PStr
134 | PChr
134 | PChr
@@ -201,10 +201,10 @@ toPatternReport source localizer patternRegion category tipe expected =
201 case context of
201 case context of
202 PTypedArg name index ->
202 PTypedArg name index ->
203 ( D.reflow $
203 ( 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."
205 , patternTypeComparison localizer tipe expectedType
205 , patternTypeComparison localizer tipe expectedType
206 (addPatternCategory "The argument is a pattern that matches" category)
206 (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
208 <> "` says the " <> D.ordinal index <> " argument should be:"
208 <> "` says the " <> D.ordinal index <> " argument should be:"
209 )
209 )
210 []
210 []
@@ -238,10 +238,10 @@ toPatternReport source localizer patternRegion category tipe expected =
238
238
239 PCtorArg name index ->
239 PCtorArg name index ->
240 ( D.reflow $
240 ( 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."
242 , patternTypeComparison localizer tipe expectedType
242 , patternTypeComparison localizer tipe expectedType
243 (addPatternCategory "It is trying to match" category)
243 (addPatternCategory "It is trying to match" category)
244− ( "But `" <> N.toString name <> "` needs its "
244+ ( "But `" <> Name.toString name <> "` needs its "
245 <> D.ordinal index <> " argument to be:"
245 <> D.ordinal index <> " argument to be:"
246 )
246 )
247 []
247 []
@@ -299,7 +299,7 @@ addPatternCategory iAmTryingToMatch category =
299 PUnit -> " unit values:"
299 PUnit -> " unit values:"
300 PTuple -> " tuples of type:"
300 PTuple -> " tuples of type:"
301 PList -> " lists of type:"
301 PList -> " lists of type:"
302− PCtor name -> " `" <> N.toString name <> "` values of type:"
302+ PCtor name -> " `" <> Name.toString name <> "` values of type:"
303 PInt -> " integers:"
303 PInt -> " integers:"
304 PStr -> " strings:"
304 PStr -> " strings:"
305 PChr -> " characters:"
305 PChr -> " characters:"
@@ -343,10 +343,10 @@ loneType localizer actual expected iAmSeeing furtherDetails =
343addCategory :: String -> Category -> String
343addCategory :: String -> Category -> String
344addCategory thisIs category =
344addCategory thisIs category =
345 case category of
345 case category of
346− Local name -> "This `" <> N.toString name <> "` value is a:"
346+ Local name -> "This `" <> Name.toString name <> "` value is a:"
347− Foreign name -> "This `" <> N.toString name <> "` value is a:"
347+ Foreign name -> "This `" <> Name.toString name <> "` value is a:"
348− Access field -> "The value at ." <> N.toString field <> " is a:"
348+ Access field -> "The value at ." <> Name.toString field <> " is a:"
349− Accessor field -> "This ." <> N.toString field <> " field access function has type:"
349+ Accessor field -> "This ." <> Name.toString field <> " field access function has type:"
350 If -> "This `if` expression produces:"
350 If -> "This `if` expression produces:"
351 Case -> "This `case` expression produces:"
351 Case -> "This `case` expression produces:"
352 List -> thisIs <> " a list of type:"
352 List -> thisIs <> " a list of type:"
@@ -363,8 +363,8 @@ addCategory thisIs category =
363 CallResult maybeName ->
363 CallResult maybeName ->
364 case maybeName of
364 case maybeName of
365 NoName -> thisIs <> ":"
365 NoName -> thisIs <> ":"
366− FuncName name -> "This `" <> N.toString name <> "` call produces:"
366+ FuncName name -> "This `" <> Name.toString name <> "` call produces:"
367− CtorName name -> "This `" <> N.toString name <> "` call produces:"
367+ CtorName name -> "This `" <> Name.toString name <> "` call produces:"
368 OpName _ -> thisIs <> ":"
368 OpName _ -> thisIs <> ":"
369
369
370
370
@@ -462,11 +462,11 @@ problemToHint problem =
462 T.FlexSuper s _ -> badRigidVar x (toASuperThing s)
462 T.FlexSuper s _ -> badRigidVar x (toASuperThing s)
463 T.RigidVar y -> badDoubleRigid x y
463 T.RigidVar y -> badDoubleRigid x y
464 T.RigidSuper _ y -> badDoubleRigid x y
464 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")
466 T.Record _ _ -> badRigidVar x "a record"
466 T.Record _ _ -> badRigidVar x "a record"
467 T.Unit -> badRigidVar x "a unit value"
467 T.Unit -> badRigidVar x "a unit value"
468 T.Tuple _ _ _ -> badRigidVar x "a tuple"
468 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")
470
470
471 T.BadRigidSuper super x tipe ->
471 T.BadRigidSuper super x tipe ->
472 case tipe of
472 case tipe of
@@ -477,11 +477,11 @@ problemToHint problem =
477 T.FlexSuper s _ -> badRigidSuper super (toASuperThing s)
477 T.FlexSuper s _ -> badRigidSuper super (toASuperThing s)
478 T.RigidVar y -> badDoubleRigid x y
478 T.RigidVar y -> badDoubleRigid x y
479 T.RigidSuper _ y -> badDoubleRigid x y
479 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")
481 T.Record _ _ -> badRigidSuper super "a record"
481 T.Record _ _ -> badRigidSuper super "a record"
482 T.Unit -> badRigidSuper super "a unit value"
482 T.Unit -> badRigidSuper super "a unit value"
483 T.Tuple _ _ _ -> badRigidSuper super "a tuple"
483 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")
485
485
486 T.FieldsMissing fields ->
486 T.FieldsMissing fields ->
487 case map (D.green . D.fromName) fields of
487 case map (D.green . D.fromName) fields of
@@ -499,7 +499,7 @@ problemToHint problem =
499
499
500
500
501 T.FieldTypo typo possibilities ->
501 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
503 [] ->
503 [] ->
504 []
504 []
505
505
@@ -519,10 +519,10 @@ problemToHint problem =
519-- BAD RIGID HINTS
519-- BAD RIGID HINTS
520
520
521
521
522−badRigidVar :: N.Name -> String -> [D.Doc]
522+badRigidVar :: Name.Name -> String -> [D.Doc]
523badRigidVar name aThing =
523badRigidVar name aThing =
524 [ D.toSimpleHint $
524 [ D.toSimpleHint $
525− "Your type annotation uses type variable `" ++ N.toString name ++
525+ "Your type annotation uses type variable `" ++ Name.toString name ++
526 "` which means ANY type of value can flow through, but your code is saying it specifically wants "
526 "` which means ANY type of value can flow through, but your code is saying it specifically wants "
527 ++ aThing ++ ". Maybe change your type annotation to\
527 ++ aThing ++ ". Maybe change your type annotation to\
528 \ be more specific? Maybe change the code to be more general?"
528 \ be more specific? Maybe change the code to be more general?"
@@ -530,10 +530,10 @@ badRigidVar name aThing =
530 ]
530 ]
531
531
532
532
533−badDoubleRigid :: N.Name -> N.Name -> [D.Doc]
533+badDoubleRigid :: Name.Name -> Name.Name -> [D.Doc]
534badDoubleRigid x y =
534badDoubleRigid x y =
535 [ D.toSimpleHint $
535 [ 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 ++
537 "` as separate type variables. Your code seems to be saying they are the\
537 "` as separate type variables. Your code seems to be saying they are the\
538 \ same though. Maybe they should be the same in your type annotation?\
538 \ same though. Maybe they should be the same in your type annotation?\
539 \ Maybe your code uses them in a weird way?"
539 \ Maybe your code uses them in a weird way?"
@@ -644,7 +644,7 @@ toExprReport source localizer exprRegion category tipe expected =
644 case subContext of
644 case subContext of
645 TypedIfBranch index -> D.ordinal index <> " branch of this `if` expression:"
645 TypedIfBranch index -> D.ordinal index <> " branch of this `if` expression:"
646 TypedCaseBranch index -> D.ordinal index <> " branch of this `case` expression:"
646 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:"
648
648
649 itIs =
649 itIs =
650 case subContext of
650 case subContext of
@@ -657,7 +657,7 @@ toExprReport source localizer exprRegion category tipe expected =
657 ( D.reflow ("Something is off with the " <> thing)
657 ( D.reflow ("Something is off with the " <> thing)
658 , typeComparison localizer tipe expectedType
658 , typeComparison localizer tipe expectedType
659 (addCategory itIs category)
659 (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:")
661 []
661 []
662 )
662 )
663
663
@@ -769,9 +769,9 @@ toExprReport source localizer exprRegion category tipe expected =
769 thisValue =
769 thisValue =
770 case maybeFuncName of
770 case maybeFuncName of
771 NoName -> "This value"
771 NoName -> "This value"
772− FuncName name -> "The `" <> N.toString name <> "` value"
772+ FuncName name -> "The `" <> Name.toString name <> "` value"
773− CtorName name -> "The `" <> N.toString name <> "` value"
773+ CtorName name -> "The `" <> Name.toString name <> "` value"
774− OpName op -> "The (" <> N.toString op <> ") operator"
774+ OpName op -> "The (" <> Name.toString op <> ") operator"
775 in
775 in
776 ( D.reflow $ thisValue <> " is not a function, but it was given " <> D.args numGivenArgs <> "."
776 ( D.reflow $ thisValue <> " is not a function, but it was given " <> D.args numGivenArgs <> "."
777 , D.reflow $ "Are there any missing commas? Or missing parentheses?"
777 , D.reflow $ "Are there any missing commas? Or missing parentheses?"
@@ -782,9 +782,9 @@ toExprReport source localizer exprRegion category tipe expected =
782 thisFunction =
782 thisFunction =
783 case maybeFuncName of
783 case maybeFuncName of
784 NoName -> "This function"
784 NoName -> "This function"
785− FuncName name -> "The `" <> N.toString name <> "` function"
785+ FuncName name -> "The `" <> Name.toString name <> "` function"
786− CtorName name -> "The `" <> N.toString name <> "` constructor"
786+ CtorName name -> "The `" <> Name.toString name <> "` constructor"
787− OpName op -> "The (" <> N.toString op <> ") operator"
787+ OpName op -> "The (" <> Name.toString op <> ") operator"
788 in
788 in
789 ( D.reflow $ thisFunction <> " expects " <> D.args n <> ", but it got " <> show numGivenArgs <> " instead."
789 ( D.reflow $ thisFunction <> " expects " <> D.args n <> ", but it got " <> show numGivenArgs <> " instead."
790 , D.reflow $ "Are there any missing commas? Or missing parentheses?"
790 , D.reflow $ "Are there any missing commas? Or missing parentheses?"
@@ -797,9 +797,9 @@ toExprReport source localizer exprRegion category tipe expected =
797 thisFunction =
797 thisFunction =
798 case maybeFuncName of
798 case maybeFuncName of
799 NoName -> "this function"
799 NoName -> "this function"
800− FuncName name -> "`" <> N.toString name <> "`"
800+ FuncName name -> "`" <> Name.toString name <> "`"
801− CtorName name -> "`" <> N.toString name <> "`"
801+ CtorName name -> "`" <> Name.toString name <> "`"
802− OpName op -> "(" <> N.toString op <> ")"
802+ OpName op -> "(" <> Name.toString op <> ")"
803 in
803 in
804 mismatch
804 mismatch
805 ( Just exprRegion
805 ( Just exprRegion
@@ -823,9 +823,9 @@ toExprReport source localizer exprRegion category tipe expected =
823 custom (Just fieldRegion)
823 custom (Just fieldRegion)
824 ( D.reflow $
824 ( D.reflow $
825 "This "
825 "This "
826− <> maybe "" (\n -> "`" <> N.toString n <> "`") maybeName
826+ <> maybe "" (\n -> "`" <> Name.toString n <> "`") maybeName
827− <> " record does not have a `" <> N.toString field <> "` field:"
827+ <> " record does not have a `" <> Name.toString field <> "` field:"
828− , case Suggest.sort (N.toString field) (N.toString . fst) (Map.toList fields) of
828+ , case Suggest.sort (Name.toString field) (Name.toString . fst) (Map.toList fields) of
829 [] ->
829 [] ->
830 D.reflow "In fact, it is a record with NO fields!"
830 D.reflow "In fact, it is a record with NO fields!"
831
831
@@ -833,7 +833,7 @@ toExprReport source localizer exprRegion category tipe expected =
833 D.stack
833 D.stack
834 [ D.reflow $
834 [ D.reflow $
835 "This is usually a typo. Here are the "
835 "This is usually a typo. Here are the "
836− <> maybe "" (\n -> "`" <> N.toString n <> "`") maybeName
836+ <> maybe "" (\n -> "`" <> Name.toString n <> "`") maybeName
837 <> " fields that are most similar:"
837 <> " fields that are most similar:"
838 , toNearbyRecord localizer f fs ext
838 , toNearbyRecord localizer f fs ext
839 , D.fillSep
839 , D.fillSep
@@ -863,7 +863,7 @@ toExprReport source localizer exprRegion category tipe expected =
863 mismatch
863 mismatch
864 ( Nothing
864 ( Nothing
865 , "Something is off with this record update:"
865 , "Something is off with this record update:"
866− , "The `" <> N.toString record <> "` record is"
866+ , "The `" <> Name.toString record <> "` record is"
867 , "But this update needs it to be compatable with:"
867 , "But this update needs it to be compatable with:"
868 , [ D.reflow
868 , [ D.reflow
869 "Do you mind creating an <http://sscce.org/> that produces this error message and\
869 "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 =
874
874
875 Just (field, Can.FieldUpdate fieldRegion _) ->
875 Just (field, Can.FieldUpdate fieldRegion _) ->
876 let
876 let
877− rStr = "`" <> N.toString record <> "`"
877+ rStr = "`" <> Name.toString record <> "`"
878− fStr = "`" <> N.toString field <> "`"
878+ fStr = "`" <> Name.toString field <> "`"
879 in
879 in
880 custom (Just fieldRegion)
880 custom (Just fieldRegion)
881 ( D.reflow $
881 ( D.reflow $
882 "The " <> rStr <> " record does not have a " <> fStr <> " field:"
882 "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
884 [] ->
884 [] ->
885 D.reflow $ "In fact, " <> rStr <> " is a record with NO fields!"
885 D.reflow $ "In fact, " <> rStr <> " is a record with NO fields!"
886
886
@@ -908,8 +908,8 @@ toExprReport source localizer exprRegion category tipe expected =
908 RecordUpdateValue field ->
908 RecordUpdateValue field ->
909 mismatch
909 mismatch
910 ( Just exprRegion
910 ( Just exprRegion
911− , "I cannot update the `" <> N.toString field <> "` field like this:"
911+ , "I cannot update the `" <> Name.toString field <> "` field like this:"
912− , "You are trying to update `" <> N.toString field <> "` to be"
912+ , "You are trying to update `" <> Name.toString field <> "` to be"
913 , "But it should be:"
913 , "But it should be:"
914 , [ D.toSimpleNote
914 , [ D.toSimpleNote
915 "The record update syntax does not allow you to change the type of fields.\
915 "The record update syntax does not allow you to change the type of fields.\
@@ -945,7 +945,7 @@ countArgs tipe =
945-- FIELD NAME HELPERS
945-- FIELD NAME HELPERS
946
946
947
947
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
949toNearbyRecord localizer f fs ext =
949toNearbyRecord localizer f fs ext =
950 D.indent 4 $
950 D.indent 4 $
951 if length fs <= 3 then
951 if length fs <= 3 then
@@ -954,7 +954,7 @@ toNearbyRecord localizer f fs ext =
954 RT.vrecordSnippet (fieldToDocs localizer f) (map (fieldToDocs localizer) (take 3 fs))
954 RT.vrecordSnippet (fieldToDocs localizer f) (map (fieldToDocs localizer) (take 3 fs))
955
955
956
956
957−fieldToDocs :: L.Localizer -> (N.Name, T.Type) -> (D.Doc, D.Doc)
957+fieldToDocs :: L.Localizer -> (Name.Name, T.Type) -> (D.Doc, D.Doc)
958fieldToDocs localizer (name, tipe) =
958fieldToDocs localizer (name, tipe) =
959 ( D.fromName name
959 ( D.fromName name
960 , T.toDoc localizer RT.None tipe
960 , T.toDoc localizer RT.None tipe
@@ -973,7 +973,7 @@ extToDoc ext =
973-- OP LEFT
973-- OP LEFT
974
974
975
975
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)
977opLeftToDocs localizer category op tipe expected =
977opLeftToDocs localizer category op tipe expected =
978 case op of
978 case op of
979 "+"
979 "+"
@@ -1008,10 +1008,10 @@ opLeftToDocs localizer category op tipe expected =
1008
1008
1009 _ ->
1009 _ ->
1010 ( D.reflow $
1010 ( D.reflow $
1011− "The left argument of (" <> N.toString op <> ") is causing problems:"
1011+ "The left argument of (" <> Name.toString op <> ") is causing problems:"
1012 , typeComparison localizer tipe expected
1012 , typeComparison localizer tipe expected
1013 (addCategory "The left argument is" category)
1013 (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:")
1015 []
1015 []
1016 )
1016 )
1017
1017
@@ -1025,7 +1025,7 @@ data RightDocs
1025 | EmphRight (D.Doc, D.Doc)
1025 | EmphRight (D.Doc, D.Doc)
1026
1026
1027
1027
1028−opRightToDocs :: L.Localizer -> Category -> N.Name -> T.Type -> T.Type -> RightDocs
1028+opRightToDocs :: L.Localizer -> Category -> Name.Name -> T.Type -> T.Type -> RightDocs
1029opRightToDocs localizer category op tipe expected =
1029opRightToDocs localizer category op tipe expected =
1030 case op of
1030 case op of
1031 "+"
1031 "+"
@@ -1099,16 +1099,16 @@ opRightToDocs localizer category op tipe expected =
1099 badOpRightFallback localizer category op tipe expected
1099 badOpRightFallback localizer category op tipe expected
1100
1100
1101
1101
1102−badOpRightFallback :: L.Localizer -> Category -> N.Name -> T.Type -> T.Type -> RightDocs
1102+badOpRightFallback :: L.Localizer -> Category -> Name.Name -> T.Type -> T.Type -> RightDocs
1103badOpRightFallback localizer category op tipe expected =
1103badOpRightFallback localizer category op tipe expected =
1104 EmphRight
1104 EmphRight
1105 ( D.reflow $
1105 ( D.reflow $
1106− "The right argument of (" <> N.toString op <> ") is causing problems."
1106+ "The right argument of (" <> Name.toString op <> ") is causing problems."
1107 , typeComparison localizer tipe expected
1107 , typeComparison localizer tipe expected
1108 (addCategory "The right argument is" category)
1108 (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:")
1110 [ D.toSimpleHint $
1110 [ 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\
1112 \ side first. If it seems fine, I assume it is correct and check the right\
1112 \ side first. If it seems fine, I assume it is correct and check the right\
1113 \ side. So the problem may be in how the left and right arguments interact!"
1113 \ side. So the problem may be in how the left and right arguments interact!"
1114 ]
1114 ]
@@ -1314,11 +1314,11 @@ badAppendRight localizer category tipe expected =
1314data ThisThenThat = FloatInt | IntFloat
1314data ThisThenThat = FloatInt | IntFloat
1315
1315
1316
1316
1317−badCast :: N.Name -> ThisThenThat -> RightDocs
1317+badCast :: Name.Name -> ThisThenThat -> RightDocs
1318badCast op thisThenThat =
1318badCast op thisThenThat =
1319 EmphBoth
1319 EmphBoth
1320 ( D.reflow $
1320 ( 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."
1322 , let
1322 , let
1323 anInt = ["an", D.dullyellow "Int"]
1323 anInt = ["an", D.dullyellow "Int"]
1324 aFloat = ["a", D.dullyellow "Float"]
1324 aFloat = ["a", D.dullyellow "Float"]
@@ -1571,13 +1571,13 @@ badEquality localizer op tipe expected =
1571-- INFINITE TYPES
1571-- INFINITE TYPES
1572
1572
1573
1573
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
1575toInfiniteReport source localizer region name overallType =
1575toInfiniteReport source localizer region name overallType =
1576 Report.Report "INFINITE TYPE" region [] $
1576 Report.Report "INFINITE TYPE" region [] $
1577 Report.toCodeSnippet source region Nothing
1577 Report.toCodeSnippet source region Nothing
1578 (
1578 (
1579 D.reflow $
1579 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 <> ":"
1581 ,
1581 ,
1582 D.stack
1582 D.stack
1583 [ D.reflow $
1583 [ D.reflow $
compiler/src/Reporting/Render/Type.hs+3−3
@@ -15,10 +15,10 @@ module Reporting.Render.Type
15
15
16
16
17import qualified Data.Maybe as Maybe
17import qualified Data.Maybe as Maybe
18+import qualified Data.Name as Name
18
19
19import qualified AST.Source as Src
20import qualified AST.Source as Src
20import qualified AST.Canonical as Can
21import qualified AST.Canonical as Can
21−import qualified Elm.Name as N
22import qualified Reporting.Annotation as A
22import qualified Reporting.Annotation as A
23import qualified Reporting.Doc as D
23import qualified Reporting.Doc as D
24import Reporting.Doc ( Doc, (<+>), (<>) )
24import Reporting.Doc ( Doc, (<+>), (<>) )
@@ -173,7 +173,7 @@ srcToDoc context (A.At _ tipe) =
173 (map (srcToDoc None) cs)
173 (map (srcToDoc None) cs)
174
174
175
175
176−srcFieldToDocs :: (A.Located N.Name, Src.Type) -> (Doc, Doc)
176+srcFieldToDocs :: (A.Located Name.Name, Src.Type) -> (Doc, Doc)
177srcFieldToDocs (A.At _ fieldName, fieldType) =
177srcFieldToDocs (A.At _ fieldName, fieldType) =
178 ( D.fromName fieldName
178 ( D.fromName fieldName
179 , srcToDoc None fieldType
179 , srcToDoc None fieldType
@@ -237,7 +237,7 @@ canToDoc localizer context tipe =
237 (map (canToDoc localizer App . snd) args)
237 (map (canToDoc localizer App . snd) args)
238
238
239
239
240−canFieldToDoc :: L.Localizer -> (N.Name, Can.Type) -> (Doc, Doc)
240+canFieldToDoc :: L.Localizer -> (Name.Name, Can.Type) -> (Doc, Doc)
241canFieldToDoc localizer (name, tipe) =
241canFieldToDoc localizer (name, tipe) =
242 ( D.fromName name
242 ( D.fromName name
243 , canToDoc localizer None tipe
243 , canToDoc localizer None tipe
compiler/src/Reporting/Render/Type/Localizer.hs+16−16
@@ -14,13 +14,13 @@ module Reporting.Render.Type.Localizer
14
14
15
15
16import qualified Data.Map as Map
16import qualified Data.Map as Map
17+import qualified Data.Name as Name
17import qualified Data.Set as Set
18import qualified Data.Set as Set
18
19
19import qualified AST.Source as Src
20import qualified AST.Source as Src
20import qualified AST.Module.Name as ModuleName
21import qualified AST.Module.Name as ModuleName
21import qualified AST.Valid as Valid
22import qualified AST.Valid as Valid
22import qualified Elm.Compiler.Imports as Imports
23import qualified Elm.Compiler.Imports as Imports
23−import qualified Elm.Name as N
24import qualified Elm.Package as Pkg
24import qualified Elm.Package as Pkg
25import Reporting.Doc ((<>))
25import Reporting.Doc ((<>))
26import qualified Reporting.Doc as D
26import qualified Reporting.Doc as D
@@ -32,19 +32,19 @@ import qualified Reporting.Annotation as A
32
32
33
33
34newtype Localizer =
34newtype Localizer =
35− Localizer (Map.Map N.Name Import)
35+ Localizer (Map.Map Name.Name Import)
36
36
37
37
38data Import =
38data Import =
39 Import
39 Import
40− { _alias :: Maybe N.Name
40+ { _alias :: Maybe Name.Name
41 , _exposing :: Exposing
41 , _exposing :: Exposing
42 }
42 }
43
43
44
44
45data Exposing
45data Exposing
46 = All
46 = All
47− | Only (Set.Set N.Name)
47+ | Only (Set.Set Name.Name)
48
48
49
49
50empty :: Localizer
50empty :: Localizer
@@ -56,36 +56,36 @@ empty =
56-- LOCALIZE
56-- LOCALIZE
57
57
58
58
59−toDoc :: Localizer -> ModuleName.Canonical -> N.Name -> D.Doc
59+toDoc :: Localizer -> ModuleName.Canonical -> Name.Name -> D.Doc
60toDoc localizer home name =
60toDoc localizer home name =
61 D.fromString (toString localizer home name)
61 D.fromString (toString localizer home name)
62
62
63
63
64−toString :: Localizer -> ModuleName.Canonical -> N.Name -> String
64+toString :: Localizer -> ModuleName.Canonical -> Name.Name -> String
65toString (Localizer localizer) moduleName@(ModuleName.Canonical _ home) name =
65toString (Localizer localizer) moduleName@(ModuleName.Canonical _ home) name =
66 case Map.lookup home localizer of
66 case Map.lookup home localizer of
67 Nothing ->
67 Nothing ->
68− N.toString home <> "." <> N.toString name
68+ Name.toString home <> "." <> Name.toString name
69
69
70 Just (Import alias exposing) ->
70 Just (Import alias exposing) ->
71 case exposing of
71 case exposing of
72 All ->
72 All ->
73− N.toString name
73+ Name.toString name
74
74
75 Only set ->
75 Only set ->
76 if Set.member name set then
76 if Set.member name set then
77− N.toString name
77+ Name.toString name
78− else if name == N.list && moduleName == ModuleName.list then
78+ else if name == Name.list && moduleName == ModuleName.list then
79 "List"
79 "List"
80 else
80 else
81− N.toString (maybe home id alias) <> "." <> N.toString name
81+ Name.toString (maybe home id alias) <> "." <> Name.toString name
82
82
83
83
84
84
85-- FROM NAMES
85-- FROM NAMES
86
86
87
87
88−fromNames :: Map.Map N.Name a -> Localizer
88+fromNames :: Map.Map Name.Name a -> Localizer
89fromNames names =
89fromNames names =
90 Localizer $ Map.map (\_ -> Import Nothing All) names
90 Localizer $ Map.map (\_ -> Import Nothing All) names
91
91
@@ -100,7 +100,7 @@ fromModule (Valid.Module name _ _ _ imports _ _ _ _ _) =
100 (name, Import Nothing All) : map toPair imports
100 (name, Import Nothing All) : map toPair imports
101
101
102
102
103−toPair :: Src.Import -> (N.Name, Import)
103+toPair :: Src.Import -> (Name.Name, Import)
104toPair (Src.Import (A.At _ name) alias exposing) =
104toPair (Src.Import (A.At _ name) alias exposing) =
105 ( name
105 ( name
106 , Import alias (toExposing exposing)
106 , Import alias (toExposing exposing)
@@ -117,7 +117,7 @@ toExposing exposing =
117 Only (foldr addType Set.empty exposedList)
117 Only (foldr addType Set.empty exposedList)
118
118
119
119
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
121addType (A.At _ exposed) types =
121addType (A.At _ exposed) types =
122 case exposed of
122 case exposed of
123 Src.Lower _ -> types
123 Src.Lower _ -> types
@@ -132,11 +132,11 @@ addType (A.At _ exposed) types =
132replEmpty :: Localizer
132replEmpty :: Localizer
133replEmpty =
133replEmpty =
134 Localizer $
134 Localizer $
135− Map.insert N.replModule (Import Nothing All) $
135+ Map.insert Name.replModule (Import Nothing All) $
136 Map.fromList $ map toPair $ Imports.addDefaults Pkg.dummyName []
136 Map.fromList $ map toPair $ Imports.addDefaults Pkg.dummyName []
137
137
138
138
139−replAdd :: N.Name -> Maybe N.Name -> Src.Exposing -> Localizer -> Localizer
139+replAdd :: Name.Name -> Maybe Name.Name -> Src.Exposing -> Localizer -> Localizer
140replAdd name alias exposing (Localizer localizer) =
140replAdd name alias exposing (Localizer localizer) =
141 Localizer $ Map.insert name (Import alias (toExposing exposing)) localizer
141 Localizer $ Map.insert name (Import alias (toExposing exposing)) localizer
142
142
compiler/src/Reporting/Warning.hs+10−10
@@ -9,10 +9,10 @@ module Reporting.Warning
9
9
10
10
11import Data.Monoid ((<>))
11import Data.Monoid ((<>))
12+import qualified Data.Name as Name
12
13
13import qualified AST.Canonical as Can
14import qualified AST.Canonical as Can
14import qualified AST.Utils.Type as Type
15import qualified AST.Utils.Type as Type
15−import qualified Elm.Name as N
16import qualified Reporting.Doc as D
16import qualified Reporting.Doc as D
17import qualified Reporting.Region as R
17import qualified Reporting.Region as R
18import qualified Reporting.Report as Report
18import qualified Reporting.Report as Report
@@ -26,9 +26,9 @@ import qualified Reporting.Render.Type.Localizer as L
26
26
27
27
28data Warning
28data Warning
29− = UnusedImport R.Region N.Name
29+ = UnusedImport R.Region Name.Name
30− | UnusedVariable R.Region Context N.Name
30+ | UnusedVariable R.Region Context Name.Name
31− | MissingTypeAnnotation R.Region N.Name Can.Type
31+ | MissingTypeAnnotation R.Region Name.Name Can.Type
32
32
33
33
34data Context = Def | Pattern
34data Context = Def | Pattern
@@ -46,7 +46,7 @@ toReport localizer source warning =
46 Report.toCodeSnippet source region Nothing
46 Report.toCodeSnippet source region Nothing
47 (
47 (
48 D.reflow $
48 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."
50 ,
50 ,
51 "I recommend removing unused imports."
51 "I recommend removing unused imports."
52 )
52 )
@@ -57,18 +57,18 @@ toReport localizer source warning =
57 Report.toCodeSnippet source region Nothing
57 Report.toCodeSnippet source region Nothing
58 (
58 (
59 D.reflow $
59 D.reflow $
60− "You are not using `" <> N.toString name <> "` anywhere."
60+ "You are not using `" <> Name.toString name <> "` anywhere."
61 ,
61 ,
62 D.stack
62 D.stack
63 [ D.reflow $
63 [ 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
65 <> "` somewhere but typed another name instead?"
65 <> "` somewhere but typed another name instead?"
66 , D.reflow $
66 , D.reflow $
67 defOrPat context
67 defOrPat context
68 ( "If you are sure there is no typo, remove the definition.\
68 ( "If you are sure there is no typo, remove the definition.\
69 \ This way future readers will not have to wonder why it is there!"
69 \ This way future readers will not have to wonder why it is there!"
70 )
70 )
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
72 <> "` with _ so future readers will not have to wonder why it is there!"
72 <> "` with _ so future readers will not have to wonder why it is there!"
73 )
73 )
74 ]
74 ]
@@ -81,10 +81,10 @@ toReport localizer source warning =
81 D.reflow $
81 D.reflow $
82 case Type.deepDealias inferredType of
82 case Type.deepDealias inferredType of
83 Can.TLambda _ _ ->
83 Can.TLambda _ _ ->
84− "The `" <> N.toString name <> "` function has no type annotation."
84+ "The `" <> Name.toString name <> "` function has no type annotation."
85
85
86 _ ->
86 _ ->
87− "The `" <> N.toString name <> "` definition has no type annotation."
87+ "The `" <> Name.toString name <> "` definition has no type annotation."
88 ,
88 ,
89 D.stack
89 D.stack
90 [ "I inferred the type annotation myself though! You can copy it into your code:"
90 [ "I inferred the type annotation myself though! You can copy it into your code:"