on master help sign in
Change "Ctor" to "Variant" / transition off Reporting.Region and Data.Text
fe41b26Evan Czaplicki
compiler/src/Reporting/Error/Canonicalize.hs+125−126
@@ -25,7 +25,6 @@ import qualified Elm.ModuleName as ModuleName
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, (<+>), (<>))
28−import qualified Reporting.Region as R
29import qualified Reporting.Render.Code as Code
28import qualified Reporting.Render.Code as Code
30import qualified Reporting.Render.Type as RT
29import qualified Reporting.Render.Type as RT
31import qualified Reporting.Report as Report
30import qualified Reporting.Report as Report
@@ -37,44 +36,44 @@ import qualified Reporting.Suggest as Suggest
37
36
38
37
39data Error
38data Error
40− = AnnotationTooShort R.Region Name.Name Index.ZeroBased Int
39+ = AnnotationTooShort A.Region Name.Name Index.ZeroBased Int
41− | AmbiguousVar R.Region (Maybe Name.Name) Name.Name [ModuleName.Canonical]
40+ | AmbiguousVar A.Region (Maybe Name.Name) Name.Name [ModuleName.Canonical]
42− | AmbiguousType R.Region (Maybe Name.Name) Name.Name [ModuleName.Canonical]
41+ | AmbiguousType A.Region (Maybe Name.Name) Name.Name [ModuleName.Canonical]
43− | AmbiguousCtor R.Region (Maybe Name.Name) Name.Name [ModuleName.Canonical]
42+ | AmbiguousVariant A.Region (Maybe Name.Name) Name.Name [ModuleName.Canonical]
44− | AmbiguousBinop R.Region Name.Name [ModuleName.Canonical]
43+ | AmbiguousBinop A.Region Name.Name [ModuleName.Canonical]
45− | BadArity R.Region BadArityContext Name.Name Int Int
44+ | BadArity A.Region BadArityContext Name.Name Int Int
46− | Binop R.Region Name.Name Name.Name
45+ | Binop A.Region Name.Name Name.Name
47− | DuplicateDecl Name.Name R.Region R.Region
46+ | DuplicateDecl Name.Name A.Region A.Region
48− | DuplicateType Name.Name R.Region R.Region
47+ | DuplicateType Name.Name A.Region A.Region
49− | DuplicateCtor Name.Name R.Region R.Region
48+ | DuplicateCtor Name.Name A.Region A.Region
50− | DuplicateBinop Name.Name R.Region R.Region
49+ | DuplicateBinop Name.Name A.Region A.Region
51− | DuplicateField Name.Name R.Region R.Region
50+ | DuplicateField Name.Name A.Region A.Region
52− | DuplicateAliasArg Name.Name Name.Name R.Region R.Region
51+ | DuplicateAliasArg Name.Name Name.Name A.Region A.Region
53− | DuplicateUnionArg Name.Name Name.Name R.Region R.Region
52+ | DuplicateUnionArg Name.Name Name.Name A.Region A.Region
54− | DuplicatePattern DuplicatePatternContext Name.Name R.Region R.Region
53+ | DuplicatePattern DuplicatePatternContext Name.Name A.Region A.Region
55− | EffectNotFound R.Region Name.Name
54+ | EffectNotFound A.Region Name.Name
56− | EffectFunctionNotFound R.Region Name.Name
55+ | EffectFunctionNotFound A.Region Name.Name
57− | ExportDuplicate Name.Name R.Region R.Region
56+ | ExportDuplicate Name.Name A.Region A.Region
58− | ExportNotFound R.Region VarKind Name.Name [Name.Name]
57+ | ExportNotFound A.Region VarKind Name.Name [Name.Name]
59− | ExportOpenAlias R.Region Name.Name
58+ | ExportOpenAlias A.Region Name.Name
60− | ImportCtorByName R.Region Name.Name Name.Name
59+ | ImportCtorByName A.Region Name.Name Name.Name
61− | ImportNotFound R.Region Name.Name [ModuleName.Canonical]
60+ | ImportNotFound A.Region Name.Name [ModuleName.Canonical]
62− | ImportOpenAlias R.Region Name.Name
61+ | ImportOpenAlias A.Region Name.Name
63− | ImportExposingNotFound R.Region ModuleName.Canonical Name.Name [Name.Name]
62+ | ImportExposingNotFound A.Region ModuleName.Canonical Name.Name [Name.Name]
64− | NotFoundVar R.Region (Maybe Name.Name) Name.Name PossibleNames
63+ | NotFoundVar A.Region (Maybe Name.Name) Name.Name PossibleNames
65− | NotFoundType R.Region (Maybe Name.Name) Name.Name PossibleNames
64+ | NotFoundType A.Region (Maybe Name.Name) Name.Name PossibleNames
66− | NotFoundCtor R.Region (Maybe Name.Name) Name.Name PossibleNames
65+ | NotFoundVariant A.Region (Maybe Name.Name) Name.Name PossibleNames
67− | NotFoundBinop R.Region Name.Name (Set.Set Name.Name)
66+ | NotFoundBinop A.Region Name.Name (Set.Set Name.Name)
68− | PatternHasRecordCtor R.Region Name.Name
67+ | PatternHasRecordCtor A.Region Name.Name
69− | PortPayloadInvalid R.Region Name.Name Can.Type InvalidPayload
68+ | PortPayloadInvalid A.Region Name.Name Can.Type InvalidPayload
70− | PortTypeInvalid R.Region Name.Name PortProblem
69+ | PortTypeInvalid A.Region Name.Name PortProblem
71− | RecursiveAlias R.Region Name.Name [Name.Name] Src.Type [Name.Name]
70+ | RecursiveAlias A.Region Name.Name [Name.Name] Src.Type [Name.Name]
72 | RecursiveDecl [Can.Def]
71 | RecursiveDecl [Can.Def]
73 | RecursiveLet (A.Located Name.Name) [Name.Name]
72 | RecursiveLet (A.Located Name.Name) [Name.Name]
74− | Shadowing Name.Name R.Region R.Region
73+ | Shadowing Name.Name A.Region A.Region
75− | TupleLargerThanThree R.Region
74+ | TupleLargerThanThree A.Region
76− | TypeVarsUnboundInUnion R.Region Name.Name [Name.Name] (Name.Name, R.Region) [(Name.Name, R.Region)]
75+ | TypeVarsUnboundInUnion A.Region Name.Name [Name.Name] (Name.Name, A.Region) [(Name.Name, A.Region)]
77− | TypeVarsMessedUpInAlias R.Region Name.Name [Name.Name] [(Name.Name, R.Region)] [(Name.Name, R.Region)]
76+ | TypeVarsMessedUpInAlias A.Region Name.Name [Name.Name] [(Name.Name, A.Region)] [(Name.Name, A.Region)]
78
77
79
78
80data BadArityContext
79data BadArityContext
@@ -155,7 +154,7 @@ toReport source err =
155 Report.toCodeSnippet source region Nothing
154 Report.toCodeSnippet source region Nothing
156 (
155 (
157 D.reflow $
156 D.reflow $
158− "The type annotation for `" <> Name.toString name <> "` says it can accept "
157+ "The type annotation for `" <> Name.toChars name <> "` says it can accept "
159 <> D.args numTypeArgs <> ", but the definition says it has "
158 <> D.args numTypeArgs <> ", but the definition says it has "
160 <> D.args numDefArgs <> ":"
159 <> D.args numDefArgs <> ":"
161 ,
160 ,
@@ -171,8 +170,8 @@ toReport source err =
171 AmbiguousType region maybePrefix name possibleHomes ->
170 AmbiguousType region maybePrefix name possibleHomes ->
172 ambiguousName source region maybePrefix name possibleHomes "type"
171 ambiguousName source region maybePrefix name possibleHomes "type"
173
172
174− AmbiguousCtor region maybePrefix name possibleHomes ->
173+ AmbiguousVariant region maybePrefix name possibleHomes ->
175− ambiguousName source region maybePrefix name possibleHomes "constructor"
174+ ambiguousName source region maybePrefix name possibleHomes "variant"
176
175
177 AmbiguousBinop region name possibleHomes ->
176 AmbiguousBinop region name possibleHomes ->
178 ambiguousName source region Nothing name possibleHomes "operator"
177 ambiguousName source region Nothing name possibleHomes "operator"
@@ -182,14 +181,14 @@ toReport source err =
182 thing =
181 thing =
183 case badArityContext of
182 case badArityContext of
184 TypeArity -> "type"
183 TypeArity -> "type"
185− PatternArity -> "constructor"
184+ PatternArity -> "variant"
186 in
185 in
187 if actual < expected then
186 if actual < expected then
188 Report.Report "TOO FEW ARGS" region [] $
187 Report.Report "TOO FEW ARGS" region [] $
189 Report.toCodeSnippet source region Nothing
188 Report.toCodeSnippet source region Nothing
190 (
189 (
191 D.reflow $
190 D.reflow $
192− "The `" <> Name.toString name <> "` " <> thing <> " needs "
191+ "The `" <> Name.toChars name <> "` " <> thing <> " needs "
193 <> D.args expected <> ", but I see " <> show actual <> " instead:"
192 <> D.args expected <> ", but I see " <> show actual <> " instead:"
194 ,
193 ,
195 D.reflow $
194 D.reflow $
@@ -201,7 +200,7 @@ toReport source err =
201 Report.toCodeSnippet source region Nothing
200 Report.toCodeSnippet source region Nothing
202 (
201 (
203 D.reflow $
202 D.reflow $
204− "The `" <> Name.toString name <> "` " <> thing <> " needs "
203+ "The `" <> Name.toChars name <> "` " <> thing <> " needs "
205 <> D.args expected <> ", but I see " <> show actual <> " instead:"
204 <> D.args expected <> ", but I see " <> show actual <> " instead:"
206 ,
205 ,
207 if actual - expected == 1 then
206 if actual - expected == 1 then
@@ -215,7 +214,7 @@ toReport source err =
215 Report.toCodeSnippet source region Nothing
214 Report.toCodeSnippet source region Nothing
216 (
215 (
217 D.reflow $
216 D.reflow $
218− "You cannot mix (" <> Name.toString op1 <> ") and (" <> Name.toString op2 <> ") without parentheses."
217+ "You cannot mix (" <> Name.toChars op1 <> ") and (" <> Name.toChars op2 <> ") without parentheses."
219 ,
218 ,
220 D.reflow
219 D.reflow
221 "I do not know how to group these expressions. Add parentheses for me!"
220 "I do not know how to group these expressions. Add parentheses for me!"
@@ -223,59 +222,59 @@ toReport source err =
223
222
224 DuplicateDecl name r1 r2 ->
223 DuplicateDecl name r1 r2 ->
225 nameClash source r1 r2 $
224 nameClash source r1 r2 $
226− "This file has multiple `" <> Name.toString name <> "` declarations."
225+ "This file has multiple `" <> Name.toChars name <> "` declarations."
227
226
228 DuplicateType name r1 r2 ->
227 DuplicateType name r1 r2 ->
229 nameClash source r1 r2 $
228 nameClash source r1 r2 $
230− "This file defines multiple `" <> Name.toString name <> "` types."
229+ "This file defines multiple `" <> Name.toChars name <> "` types."
231
230
232 DuplicateCtor name r1 r2 ->
231 DuplicateCtor name r1 r2 ->
233 nameClash source r1 r2 $
232 nameClash source r1 r2 $
234− "This file defines multiple `" <> Name.toString name <> "` type constructors."
233+ "This file defines multiple `" <> Name.toChars name <> "` type constructors."
235
234
236 DuplicateBinop name r1 r2 ->
235 DuplicateBinop name r1 r2 ->
237 nameClash source r1 r2 $
236 nameClash source r1 r2 $
238− "This file defines multiple (" <> Name.toString name <> ") operators."
237+ "This file defines multiple (" <> Name.toChars name <> ") operators."
239
238
240 DuplicateField name r1 r2 ->
239 DuplicateField name r1 r2 ->
241 nameClash source r1 r2 $
240 nameClash source r1 r2 $
242− "This record has multiple `" <> Name.toString name <> "` fields."
241+ "This record has multiple `" <> Name.toChars name <> "` fields."
243
242
244 DuplicateAliasArg typeName name r1 r2 ->
243 DuplicateAliasArg typeName name r1 r2 ->
245 nameClash source r1 r2 $
244 nameClash source r1 r2 $
246− "The `" <> Name.toString typeName <> "` type alias has multilpe `" <> Name.toString name <> "` type variables."
245+ "The `" <> Name.toChars typeName <> "` type alias has multilpe `" <> Name.toChars name <> "` type variables."
247
246
248 DuplicateUnionArg typeName name r1 r2 ->
247 DuplicateUnionArg typeName name r1 r2 ->
249 nameClash source r1 r2 $
248 nameClash source r1 r2 $
250− "The `" <> Name.toString typeName <> "` type has multilpe `" <> Name.toString name <> "` type variables."
249+ "The `" <> Name.toChars typeName <> "` type has multilpe `" <> Name.toChars name <> "` type variables."
251
250
252 DuplicatePattern context name r1 r2 ->
251 DuplicatePattern context name r1 r2 ->
253 nameClash source r1 r2 $
252 nameClash source r1 r2 $
254 case context of
253 case context of
255 DPLambdaArgs ->
254 DPLambdaArgs ->
256− "This anonymous function has multiple `" <> Name.toString name <> "` arguments."
255+ "This anonymous function has multiple `" <> Name.toChars name <> "` arguments."
257
256
258 DPFuncArgs funcName ->
257 DPFuncArgs funcName ->
259− "The `" <> Name.toString funcName <> "` function has multiple `" <> Name.toString name <> "` arguments."
258+ "The `" <> Name.toChars funcName <> "` function has multiple `" <> Name.toChars name <> "` arguments."
260
259
261 DPCaseBranch ->
260 DPCaseBranch ->
262− "This `case` pattern has multiple `" <> Name.toString name <> "` variables."
261+ "This `case` pattern has multiple `" <> Name.toChars name <> "` variables."
263
262
264 DPLetBinding ->
263 DPLetBinding ->
265− "This `let` expression defines `" <> Name.toString name <> "` more than once!"
264+ "This `let` expression defines `" <> Name.toChars name <> "` more than once!"
266
265
267 DPDestruct ->
266 DPDestruct ->
268− "This pattern contains multiple `" <> Name.toString name <> "` variables."
267+ "This pattern contains multiple `" <> Name.toChars name <> "` variables."
269
268
270 EffectNotFound region name ->
269 EffectNotFound region name ->
271 Report.Report "EFFECT PROBLEM" region [] $
270 Report.Report "EFFECT PROBLEM" region [] $
272 Report.toCodeSnippet source region Nothing
271 Report.toCodeSnippet source region Nothing
273 (
272 (
274 D.reflow $
273 D.reflow $
275− "You have declared that `" ++ Name.toString name ++ "` is an effect type:"
274+ "You have declared that `" ++ Name.toChars name ++ "` is an effect type:"
276 ,
275 ,
277 D.reflow $
276 D.reflow $
278− "But I cannot find a union type named `" ++ Name.toString name ++ "` in this file!"
277+ "But I cannot find a union type named `" ++ Name.toChars name ++ "` in this file!"
279 )
278 )
280
279
281 EffectFunctionNotFound region name ->
280 EffectFunctionNotFound region name ->
@@ -283,17 +282,17 @@ toReport source err =
283 Report.toCodeSnippet source region Nothing
282 Report.toCodeSnippet source region Nothing
284 (
283 (
285 D.reflow $
284 D.reflow $
286− "This kind of effect module must define a `" ++ Name.toString name ++ "` function."
285+ "This kind of effect module must define a `" ++ Name.toChars name ++ "` function."
287 ,
286 ,
288 D.reflow $
287 D.reflow $
289− "But I cannot find `" ++ Name.toString name ++ "` in this file!"
288+ "But I cannot find `" ++ Name.toChars name ++ "` in this file!"
290 )
289 )
291
290
292
291
293 ExportDuplicate name r1 r2 ->
292 ExportDuplicate name r1 r2 ->
294 let
293 let
295 messageThatEndsWithPunctuation =
294 messageThatEndsWithPunctuation =
296− "You are trying to expose `" <> Name.toString name <> "` multiple times!"
295+ "You are trying to expose `" <> Name.toChars name <> "` multiple times!"
297 in
296 in
298 Report.Report "REDUNDANT EXPORT" r2 [] $
297 Report.Report "REDUNDANT EXPORT" r2 [] $
299 Report.toCodePair source r1 r2
298 Report.toCodePair source r1 r2
@@ -313,8 +312,8 @@ toReport source err =
313 ExportNotFound region kind rawName possibleNames ->
312 ExportNotFound region kind rawName possibleNames ->
314 let
313 let
315 suggestions =
314 suggestions =
316− map Name.toString $ take 4 $
315+ map Name.toChars $ take 4 $
317− Suggest.sort (Name.toString rawName) Name.toString possibleNames
316+ Suggest.sort (Name.toChars rawName) Name.toChars possibleNames
318 in
317 in
319 Report.Report "UNKNOWN EXPORT" region suggestions $
318 Report.Report "UNKNOWN EXPORT" region suggestions $
320 let (a, thing, name) = toKindInfo kind rawName in
319 let (a, thing, name) = toKindInfo kind rawName in
@@ -323,7 +322,7 @@ toReport source err =
323 ["You","are","trying","to","expose",a,thing,"named"
322 ["You","are","trying","to","expose",a,thing,"named"
324 ,name,"but","I","cannot","find","its","definition."
323 ,name,"but","I","cannot","find","its","definition."
325 ]
324 ]
326− , case map D.fromString suggestions of
325+ , case map D.fromChars suggestions of
327 [] ->
326 [] ->
328 D.reflow $
327 D.reflow $
329 "I do not see any super similar names in this file. Is the definition missing?"
328 "I do not see any super similar names in this file. Is the definition missing?"
@@ -344,7 +343,7 @@ toReport source err =
344 (
343 (
345 D.reflow $
344 D.reflow $
346 "The (..) syntax is for exposing union type constructors. It cannot be used with a type alias like `"
345 "The (..) syntax is for exposing union type constructors. It cannot be used with a type alias like `"
347− ++ Name.toString name ++ "` though."
346+ ++ Name.toChars name ++ "` though."
348 ,
347 ,
349 D.reflow $
348 D.reflow $
350 "Remove the (..) and you should be fine!"
349 "Remove the (..) and you should be fine!"
@@ -355,7 +354,7 @@ toReport source err =
355 Report.toCodeSnippet source region Nothing
354 Report.toCodeSnippet source region Nothing
356 (
355 (
357 D.reflow $
356 D.reflow $
358− "You are trying to import the `" <> Name.toString ctor
357+ "You are trying to import the `" <> Name.toChars ctor
359 <> "` type constructor by name:"
358 <> "` type constructor by name:"
360 ,
359 ,
361 D.fillSep
360 D.fillSep
@@ -375,7 +374,7 @@ toReport source err =
375 Report.toCodeSnippet source region Nothing
374 Report.toCodeSnippet source region Nothing
376 (
375 (
377 D.reflow $
376 D.reflow $
378− "I could not find a `" <> Name.toString name <> "` module to import!"
377+ "I could not find a `" <> Name.toChars name <> "` module to import!"
379 ,
378 ,
380 mempty
379 mempty
381 )
380 )
@@ -385,7 +384,7 @@ toReport source err =
385 Report.toCodeSnippet source region Nothing
384 Report.toCodeSnippet source region Nothing
386 (
385 (
387 D.reflow $
386 D.reflow $
388− "The `" <> Name.toString name <> "` type alias cannot be followed by (..) like this:"
387+ "The `" <> Name.toChars name <> "` type alias cannot be followed by (..) like this:"
389 ,
388 ,
390 D.stack
389 D.stack
391 [ "Remove the (..) and it should work."
390 [ "Remove the (..) and it should work."
@@ -399,18 +398,18 @@ toReport source err =
399 ImportExposingNotFound region (ModuleName.Canonical _ home) value possibleNames ->
398 ImportExposingNotFound region (ModuleName.Canonical _ home) value possibleNames ->
400 let
399 let
401 suggestions =
400 suggestions =
402− map Name.toString $ take 4 $
401+ map Name.toChars $ take 4 $
403− Suggest.sort (Name.toString home) Name.toString possibleNames
402+ Suggest.sort (Name.toChars home) Name.toChars possibleNames
404 in
403 in
405 Report.Report "BAD IMPORT" region suggestions $
404 Report.Report "BAD IMPORT" region suggestions $
406 Report.toCodeSnippet source region Nothing
405 Report.toCodeSnippet source region Nothing
407 (
406 (
408 D.reflow $
407 D.reflow $
409− "The `" <> Name.toString home
408+ "The `" <> Name.toChars home
410 <> "` module does not expose `"
409 <> "` module does not expose `"
411− <> Name.toString value <> "`:"
410+ <> Name.toChars value <> "`:"
412 ,
411 ,
413− case map D.fromString suggestions of
412+ case map D.fromChars suggestions of
414 [] ->
413 [] ->
415 "I cannot find any super similar exposed names. Maybe it is private?"
414 "I cannot find any super similar exposed names. Maybe it is private?"
416
415
@@ -430,8 +429,8 @@ toReport source err =
430 NotFoundType region prefix name possibleNames ->
429 NotFoundType region prefix name possibleNames ->
431 notFound source region prefix name "type" possibleNames
430 notFound source region prefix name "type" possibleNames
432
431
433− NotFoundCtor region prefix name possibleNames ->
432+ NotFoundVariant region prefix name possibleNames ->
434− notFound source region prefix name "constructor" possibleNames
433+ notFound source region prefix name "variant" possibleNames
435
434
436 NotFoundBinop region op locals ->
435 NotFoundBinop region op locals ->
437 if op == "===" then
436 if op == "===" then
@@ -454,7 +453,7 @@ toReport source err =
454 [ D.reflow "Switch to (/=) instead."
453 [ D.reflow "Switch to (/=) instead."
455 , D.toSimpleNote $
454 , D.toSimpleNote $
456 "Our (/=) operator is supposed to look like a real “not equal” sign (≠). I hope that history will remember ("
455 "Our (/=) operator is supposed to look like a real “not equal” sign (≠). I hope that history will remember ("
457− ++ Name.toString op ++ ") as a weird and temporary choice."
456+ ++ Name.toChars op ++ ") as a weird and temporary choice."
458 ]
457 ]
459 )
458 )
460
459
@@ -491,8 +490,8 @@ toReport source err =
491 else
490 else
492 let
491 let
493 suggestions =
492 suggestions =
494− map Name.toString $ take 2 $
493+ map Name.toChars $ take 2 $
495− Suggest.sort (Name.toString op) Name.toString (Set.toList locals)
494+ Suggest.sort (Name.toChars op) Name.toChars (Set.toList locals)
496
495
497 format altOp =
496 format altOp =
498 D.green $ "(" <> altOp <> ")"
497 D.green $ "(" <> altOp <> ")"
@@ -501,12 +500,12 @@ toReport source err =
501 Report.toCodeSnippet source region Nothing
500 Report.toCodeSnippet source region Nothing
502 (
501 (
503 D.reflow $
502 D.reflow $
504− "I do not recognize the (" ++ Name.toString op ++ ") operator."
503+ "I do not recognize the (" ++ Name.toChars op ++ ") operator."
505 ,
504 ,
506 D.fillSep $
505 D.fillSep $
507 ["Is","there","an","`import`","and","`exposing`","entry","for","it?"]
506 ["Is","there","an","`import`","and","`exposing`","entry","for","it?"]
508 ++
507 ++
509− case map D.fromString suggestions of
508+ case map D.fromChars suggestions of
510 [] ->
509 [] ->
511 []
510 []
512
511
@@ -519,7 +518,7 @@ toReport source err =
519 Report.toCodeSnippet source region Nothing
518 Report.toCodeSnippet source region Nothing
520 (
519 (
521 D.reflow $
520 D.reflow $
522− "You can construct records by using `" <> Name.toString name
521+ "You can construct records by using `" <> Name.toChars name
523 <> "` as a function, but it is not available in pattern matching like this:"
522 <> "` as a function, but it is not available in pattern matching like this:"
524 ,
523 ,
525 D.reflow $
524 D.reflow $
@@ -533,7 +532,7 @@ toReport source err =
533 Report.toCodeSnippet source region Nothing
532 Report.toCodeSnippet source region Nothing
534 (
533 (
535 D.reflow $
534 D.reflow $
536− "The `" <> Name.toString portName <> "` port is trying to transmit " <> aBadKindOfThing <> ":"
535+ "The `" <> Name.toChars portName <> "` port is trying to transmit " <> aBadKindOfThing <> ":"
537 ,
536 ,
538 D.stack
537 D.stack
539 [ elaboration
538 [ elaboration
@@ -570,14 +569,14 @@ toReport source err =
570 "an unspecified type"
569 "an unspecified type"
571 ,
570 ,
572 D.reflow $
571 D.reflow $
573− "But type variables like `" <> Name.toString name <> "` cannot flow through ports.\
572+ "But type variables like `" <> Name.toChars name <> "` cannot flow through ports.\
574 \ I need to know exactly what type of data I am getting, so I can guarantee that\
573 \ 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."
574 \ unexpected data cannot sneak in and crash the Elm program."
576 )
575 )
577
576
578 UnsupportedType name ->
577 UnsupportedType name ->
579 (
578 (
580− "a `" <> Name.toString name <> "` value"
579+ "a `" <> Name.toChars name <> "` value"
581 ,
580 ,
582 D.stack
581 D.stack
583 [ D.reflow $ "I cannot handle that. The types that CAN flow in and out of Elm include:"
582 [ D.reflow $ "I cannot handle that. The types that CAN flow in and out of Elm include:"
@@ -611,7 +610,7 @@ toReport source err =
611 case portProblem of
610 case portProblem of
612 CmdNoArg ->
611 CmdNoArg ->
613 (
612 (
614− "The `" <> Name.toString name <> "` port cannot be just a command."
613+ "The `" <> Name.toChars name <> "` port cannot be just a command."
615 ,
614 ,
616 D.reflow $
615 D.reflow $
617 "It can be (() -> Cmd msg) if you just need to trigger a JavaScript\
616 "It can be (() -> Cmd msg) if you just need to trigger a JavaScript\
@@ -620,7 +619,7 @@ toReport source err =
620
619
621 CmdExtraArgs n ->
620 CmdExtraArgs n ->
622 (
621 (
623− "The `" <> Name.toString name <> "` port can only send ONE value out to JavaScript."
622+ "The `" <> Name.toChars name <> "` port can only send ONE value out to JavaScript."
624 ,
623 ,
625 let
624 let
626 theseItemsInSomething
625 theseItemsInSomething
@@ -634,7 +633,7 @@ toReport source err =
634
633
635 CmdBadMsg ->
634 CmdBadMsg ->
636 (
635 (
637− "The `" <> Name.toString name <> "` port cannot send any messages to the `update` function."
636+ "The `" <> Name.toChars name <> "` port cannot send any messages to the `update` function."
638 ,
637 ,
639 D.reflow $
638 D.reflow $
640 "It must produce a (Cmd msg) type. Notice the lower case `msg` type\
639 "It must produce a (Cmd msg) type. Notice the lower case `msg` type\
@@ -643,13 +642,13 @@ toReport source err =
643 )
642 )
644
643
645 SubBad ->
644 SubBad ->
646− ( "There is something off about this `" <> Name.toString name <> "` port declaration."
645+ ( "There is something off about this `" <> Name.toChars name <> "` port declaration."
647 ,
646 ,
648 D.stack
647 D.stack
649 [ D.reflow $
648 [ D.reflow $
650 "To receive messages from JavaScript, you need to define a port like this:"
649 "To receive messages from JavaScript, you need to define a port like this:"
651− , D.indent 4 $ D.dullyellow $ D.fromString $
650+ , D.indent 4 $ D.dullyellow $ D.fromChars $
652− "port " <> Name.toString name <> " : (Int -> msg) -> Sub msg"
651+ "port " <> Name.toChars name <> " : (Int -> msg) -> Sub msg"
653 , D.reflow $
652 , D.reflow $
654 "Now every time JS sends an `Int` to this port, it is converted to a `msg`.\
653 "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`\
654 \ And if you subscribe, those `msg` values will be piped into your `update`\
@@ -659,7 +658,7 @@ toReport source err =
659
658
660 NotCmdOrSub ->
659 NotCmdOrSub ->
661 (
660 (
662− "I am confused about the `" <> Name.toString name <> "` port declaration."
661+ "I am confused about the `" <> Name.toChars name <> "` port declaration."
663 ,
662 ,
664 D.reflow $
663 D.reflow $
665 "Ports need to produce a command (Cmd) or a subscription (Sub) but\
664 "Ports need to produce a command (Cmd) or a subscription (Sub) but\
@@ -677,7 +676,7 @@ toReport source err =
677 Can.TypedDef name _ _ _ _ -> name
676 Can.TypedDef name _ _ _ _ -> name
678
677
679 makeTheory question details =
678 makeTheory question details =
680− D.fillSep $ map (D.dullyellow . D.fromString) (words question) ++ map D.fromString (words details)
679+ D.fillSep $ map (D.dullyellow . D.fromChars) (words question) ++ map D.fromChars (words details)
681 in
680 in
682 case map toName cyclicValueDefs of
681 case map toName cyclicValueDefs of
683 [] ->
682 [] ->
@@ -693,16 +692,16 @@ toReport source err =
693 [] ->
692 [] ->
694 (
693 (
695 D.reflow $
694 D.reflow $
696− "The `" <> Name.toString name <> "` value is defined directly in terms of itself, causing an infinite loop."
695+ "The `" <> Name.toChars name <> "` value is defined directly in terms of itself, causing an infinite loop."
697 ,
696 ,
698 D.stack
697 D.stack
699 [ makeTheory "Are you are trying to mutate a variable?" $
698 [ makeTheory "Are you are trying to mutate a variable?" $
700− "Elm does not have mutation, so when I see " ++ Name.toString name
699+ "Elm does not have mutation, so when I see " ++ Name.toChars name
701− ++ " defined in terms of " ++ Name.toString name
700+ ++ " defined in terms of " ++ Name.toChars name
702 ++ ", I treat it as a recursive definition. Try giving the new value a new name!"
701 ++ ", I treat it as a recursive definition. Try giving the new value a new name!"
703 , makeTheory "Maybe you DO want a recursive value?" $
702 , makeTheory "Maybe you DO want a recursive value?" $
704− "To define " ++ Name.toString name ++ " we need to know what " ++ Name.toString name
703+ "To define " ++ Name.toChars name ++ " we need to know what " ++ Name.toChars name
705− ++ " is, so let’s expand it. Wait, but now we need to know what " ++ Name.toString name
704+ ++ " is, so let’s expand it. Wait, but now we need to know what " ++ Name.toChars name
706 ++ " is, so let’s expand it... This will keep going infinitely!"
705 ++ " is, so let’s expand it... This will keep going infinitely!"
707 , D.link "Hint"
706 , D.link "Hint"
708 "The root problem is often a typo in some variable name, but I recommend reading"
707 "The root problem is often a typo in some variable name, but I recommend reading"
@@ -714,11 +713,11 @@ toReport source err =
714 names ->
713 names ->
715 (
714 (
716 D.reflow $
715 D.reflow $
717− "The `" <> Name.toString name <> "` definition is causing a very tricky infinite loop."
716+ "The `" <> Name.toChars name <> "` definition is causing a very tricky infinite loop."
718 ,
717 ,
719 D.stack
718 D.stack
720 [ D.reflow $
719 [ D.reflow $
721− "The `" <> Name.toString name
720+ "The `" <> Name.toChars name
722 <> "` value depends on itself through the following chain of definitions:"
721 <> "` value depends on itself through the following chain of definitions:"
723 , D.cycle 4 (name:names)
722 , D.cycle 4 (name:names)
724 , D.link "Hint"
723 , D.link "Hint"
@@ -735,20 +734,20 @@ toReport source err =
735 [] ->
734 [] ->
736 let
735 let
737 makeTheory question details =
736 makeTheory question details =
738− D.fillSep $ map (D.dullyellow . D.fromString) (words question) ++ map D.fromString (words details)
737+ D.fillSep $ map (D.dullyellow . D.fromChars) (words question) ++ map D.fromChars (words details)
739 in
738 in
740 (
739 (
741 D.reflow $
740 D.reflow $
742− "The `" <> Name.toString name <> "` value is defined directly in terms of itself, causing an infinite loop."
741+ "The `" <> Name.toChars name <> "` value is defined directly in terms of itself, causing an infinite loop."
743 ,
742 ,
744 D.stack
743 D.stack
745 [ makeTheory "Are you are trying to mutate a variable?" $
744 [ makeTheory "Are you are trying to mutate a variable?" $
746− "Elm does not have mutation, so when I see " ++ Name.toString name
745+ "Elm does not have mutation, so when I see " ++ Name.toChars name
747− ++ " defined in terms of " ++ Name.toString name
746+ ++ " defined in terms of " ++ Name.toChars name
748 ++ ", I treat it as a recursive definition. Try giving the new value a new name!"
747 ++ ", I treat it as a recursive definition. Try giving the new value a new name!"
749 , makeTheory "Maybe you DO want a recursive value?" $
748 , makeTheory "Maybe you DO want a recursive value?" $
750− "To define " ++ Name.toString name ++ " we need to know what " ++ Name.toString name
749+ "To define " ++ Name.toChars name ++ " we need to know what " ++ Name.toChars name
751− ++ " is, so let’s expand it. Wait, but now we need to know what " ++ Name.toString name
750+ ++ " is, so let’s expand it. Wait, but now we need to know what " ++ Name.toChars name
752 ++ " is, so let’s expand it... This will keep going infinitely!"
751 ++ " is, so let’s expand it... This will keep going infinitely!"
753 , D.link "Hint"
752 , D.link "Hint"
754 "The root problem is often a typo in some variable name, but I recommend reading"
753 "The root problem is often a typo in some variable name, but I recommend reading"
@@ -764,7 +763,7 @@ toReport source err =
764 ,
763 ,
765 D.stack
764 D.stack
766 [ D.reflow $
765 [ D.reflow $
767− "The `" <> Name.toString name
766+ "The `" <> Name.toChars name
768 <> "` value depends on itself through the following chain of definitions:"
767 <> "` value depends on itself through the following chain of definitions:"
769 , D.cycle 4 (name:names)
768 , D.cycle 4 (name:names)
770 , D.link "Hint"
769 , D.link "Hint"
@@ -780,7 +779,7 @@ toReport source err =
780 ( "These variables cannot have the same name:"
779 ( "These variables cannot have the same name:"
781 , advice
780 , advice
782 )
781 )
783− ( D.reflow $ "The name `" <> Name.toString name <> "` is first defined here:"
782+ ( D.reflow $ "The name `" <> Name.toChars name <> "` is first defined here:"
784 , "But then it is defined AGAIN over here:"
783 , "But then it is defined AGAIN over here:"
785 , advice
784 , advice
786 )
785 )
@@ -902,7 +901,7 @@ toReport source err =
902 Report.toCodeSnippet source aliasRegion Nothing
901 Report.toCodeSnippet source aliasRegion Nothing
903 (
902 (
904 D.reflow $
903 D.reflow $
905− "Type alias `" <> Name.toString typeName <> "` has some type variable problems."
904+ "Type alias `" <> Name.toChars typeName <> "` has some type variable problems."
906 ,
905 ,
907 D.stack
906 D.stack
908 [ D.fillSep $ theseAreUsed ++ butTheseAreUnused
907 [ D.fillSep $ theseAreUsed ++ butTheseAreUnused
@@ -921,7 +920,7 @@ toReport source err =
921-- BAD TYPE VARIABLES
920-- BAD TYPE VARIABLES
922
921
923
922
924−unboundTypeVars :: Code.Source -> R.Region -> [D.Doc] -> Name.Name -> [Name.Name] -> (Name.Name, R.Region) -> [(Name.Name, R.Region)] -> Report.Report
923+unboundTypeVars :: Code.Source -> A.Region -> [D.Doc] -> Name.Name -> [Name.Name] -> (Name.Name, A.Region) -> [(Name.Name, A.Region)] -> Report.Report
925unboundTypeVars source declRegion tipe typeName allVars (unboundVar, varRegion) unboundVars =
924unboundTypeVars source declRegion tipe typeName allVars (unboundVar, varRegion) unboundVars =
926 let
925 let
927 backQuote name =
926 backQuote name =
@@ -960,7 +959,7 @@ unboundTypeVars source declRegion tipe typeName allVars (unboundVar, varRegion)
960 ++ map (D.green . D.fromName) (unboundVar : map fst unboundVars)
959 ++ map (D.green . D.fromName) (unboundVar : map fst unboundVars)
961 ++ ["=", "..."]
960 ++ ["=", "..."]
962 , D.reflow $
961 , D.reflow $
963− "Why? Well, imagine one `" ++ Name.toString typeName ++ "` where `" ++ Name.toString unboundVar ++
962+ "Why? Well, imagine one `" ++ Name.toChars typeName ++ "` where `" ++ Name.toChars unboundVar ++
964 "` is an Int and another where it is a Bool. When we explicitly list the type\
963 "` 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."
964 \ variables, the type checker can see that they are actually different types."
966 ]
965 ]
@@ -971,7 +970,7 @@ unboundTypeVars source declRegion tipe typeName allVars (unboundVar, varRegion)
971-- NAME CLASH
970-- NAME CLASH
972
971
973
972
974−nameClash :: Code.Source -> R.Region -> R.Region -> String -> Report.Report
973+nameClash :: Code.Source -> A.Region -> A.Region -> String -> Report.Report
975nameClash source r1 r2 messageThatEndsWithPunctuation =
974nameClash source r1 r2 messageThatEndsWithPunctuation =
976 Report.Report "NAME CLASH" r2 [] $
975 Report.Report "NAME CLASH" r2 [] $
977 Report.toCodePair source r1 r2
976 Report.toCodePair source r1 r2
@@ -993,7 +992,7 @@ nameClash source r1 r2 messageThatEndsWithPunctuation =
993-- AMBIGUOUS NAME
992-- AMBIGUOUS NAME
994
993
995
994
996−ambiguousName :: Code.Source -> R.Region -> Maybe Name.Name -> Name.Name -> [ModuleName.Canonical] -> String -> Report.Report
995+ambiguousName :: Code.Source -> A.Region -> Maybe Name.Name -> Name.Name -> [ModuleName.Canonical] -> String -> Report.Report
997ambiguousName source region maybePrefix name possibleHomes thing =
996ambiguousName source region maybePrefix name possibleHomes thing =
998 Report.Report "AMBIGUOUS NAME" region [] $
997 Report.Report "AMBIGUOUS NAME" region [] $
999 Report.toCodeSnippet source region Nothing $
998 Report.toCodeSnippet source region Nothing $
@@ -1007,12 +1006,12 @@ ambiguousName source region maybePrefix name possibleHomes thing =
1007 if length possibleHomes == 2 then "both" else "all"
1006 if length possibleHomes == 2 then "both" else "all"
1008 in
1007 in
1009 (
1008 (
1010− D.reflow $ "This usage of `" ++ Name.toString name ++ "` is ambiguous."
1009+ D.reflow $ "This usage of `" ++ Name.toChars name ++ "` is ambiguous."
1011 ,
1010 ,
1012 D.stack
1011 D.stack
1013 [ D.reflow $
1012 [ D.reflow $
1014 "Check your imports. The following modules " ++ bothOrAll
1013 "Check your imports. The following modules " ++ bothOrAll
1015− ++ " expose a `" ++ Name.toString name ++ "` " ++ thing ++ ":"
1014+ ++ " expose a `" ++ Name.toChars name ++ "` " ++ thing ++ ":"
1016 , D.indent 4 $ D.vcat $ map homeToYellowDoc possibleHomes
1015 , D.indent 4 $ D.vcat $ map homeToYellowDoc possibleHomes
1017 , D.reflowLink "Read" "imports" "to learn how to clarify which one you want."
1016 , D.reflowLink "Read" "imports" "to learn how to clarify which one you want."
1018 ]
1017 ]
@@ -1046,18 +1045,18 @@ ambiguousName source region maybePrefix name possibleHomes thing =
1046-- NOT FOUND
1045-- NOT FOUND
1047
1046
1048
1047
1049−notFound :: Code.Source -> R.Region -> Maybe Name.Name -> Name.Name -> String -> PossibleNames -> Report.Report
1048+notFound :: Code.Source -> A.Region -> Maybe Name.Name -> Name.Name -> String -> PossibleNames -> Report.Report
1050notFound source region maybePrefix name thing (PossibleNames locals quals) =
1049notFound source region maybePrefix name thing (PossibleNames locals quals) =
1051 let
1050 let
1052 givenName =
1051 givenName =
1053− maybe Name.toString toQualString maybePrefix name
1052+ maybe Name.toChars toQualString maybePrefix name
1054
1053
1055 possibleNames =
1054 possibleNames =
1056 let
1055 let
1057 addQuals prefix localSet allNames =
1056 addQuals prefix localSet allNames =
1058 Set.foldr (\x xs -> toQualString prefix x : xs) allNames localSet
1057 Set.foldr (\x xs -> toQualString prefix x : xs) allNames localSet
1059 in
1058 in
1060− Map.foldrWithKey addQuals (map Name.toString (Set.toList locals)) quals
1059+ Map.foldrWithKey addQuals (map Name.toChars (Set.toList locals)) quals
1061
1060
1062 nearbyNames =
1061 nearbyNames =
1063 take 4 (Suggest.sort givenName id possibleNames)
1062 take 4 (Suggest.sort givenName id possibleNames)
@@ -1073,7 +1072,7 @@ notFound source region maybePrefix name thing (PossibleNames locals quals) =
1073 suggestions ->
1072 suggestions ->
1074 D.stack
1073 D.stack
1075 [ D.reflow yesSuggestionDetails
1074 [ D.reflow yesSuggestionDetails
1076− , D.indent 4 $ D.vcat $ map D.dullyellow $ map D.fromString suggestions
1075+ , D.indent 4 $ D.vcat $ map D.dullyellow $ map D.fromChars suggestions
1077 , D.link "Hint" "Read" "imports" "to see how `import` declarations work in Elm."
1076 , D.link "Hint" "Read" "imports" "to see how `import` declarations work in Elm."
1078 ]
1077 ]
1079
1078
@@ -1094,19 +1093,19 @@ notFound source region maybePrefix name thing (PossibleNames locals quals) =
1094 case Map.lookup prefix quals of
1093 case Map.lookup prefix quals of
1095 Nothing ->
1094 Nothing ->
1096 toDetails
1095 toDetails
1097− ("I cannot find a `" ++ Name.toString prefix ++ "` module. Is there an `import` for it?")
1096+ ("I cannot find a `" ++ Name.toChars prefix ++ "` module. Is there an `import` for it?")
1098− ("I cannot find a `" ++ Name.toString prefix ++ "` import. These names seem close though:")
1097+ ("I cannot find a `" ++ Name.toChars prefix ++ "` import. These names seem close though:")
1099
1098
1100 Just _ ->
1099 Just _ ->
1101 toDetails
1100 toDetails
1102− ("The `" ++ Name.toString prefix ++ "` module does not expose a `" ++ Name.toString name ++ "` " ++ thing ++ ".")
1101+ ("The `" ++ Name.toChars prefix ++ "` module does not expose a `" ++ Name.toChars name ++ "` " ++ thing ++ ".")
1103− ("The `" ++ Name.toString prefix ++ "` module does not expose a `" ++ Name.toString name ++ "` " ++ thing ++ ". These names seem close though:")
1102+ ("The `" ++ Name.toChars prefix ++ "` module does not expose a `" ++ Name.toChars name ++ "` " ++ thing ++ ". These names seem close though:")
1104 )
1103 )
1105
1104
1106
1105
1107toQualString :: Name.Name -> Name.Name -> String
1106toQualString :: Name.Name -> Name.Name -> String
1108toQualString prefix name =
1107toQualString prefix name =
1109− Name.toString prefix ++ "." ++ Name.toString name
1108+ Name.toChars prefix ++ "." ++ Name.toChars name
1110
1109
1111
1110
1112
1111
@@ -1200,7 +1199,7 @@ modHint =
1200-- ARG MISMATCH
1199-- ARG MISMATCH
1201
1200
1202
1201
1203−_argMismatchReport :: Code.Source -> R.Region -> String -> Name.Name -> Int -> Int -> Report.Report
1202+_argMismatchReport :: Code.Source -> A.Region -> String -> Name.Name -> Int -> Int -> Report.Report
1204_argMismatchReport source region kind name expected actual =
1203_argMismatchReport source region kind name expected actual =
1205 let
1204 let
1206 numArgs =
1205 numArgs =
@@ -1212,7 +1211,7 @@ _argMismatchReport source region kind name expected actual =
1212 Report.toCodeSnippet source region Nothing
1211 Report.toCodeSnippet source region Nothing
1213 (
1212 (
1214 D.reflow $
1213 D.reflow $
1215− kind <> " " <> Name.toString name <> " has " <> numArgs <> "."
1214+ kind <> " " <> Name.toChars name <> " has " <> numArgs <> "."
1216 ,
1215 ,
1217 D.reflow $
1216 D.reflow $
1218 "Expecting " <> show expected <> ", but got " <> show actual <> "."
1217 "Expecting " <> show expected <> ", but got " <> show actual <> "."
@@ -1223,7 +1222,7 @@ _argMismatchReport source region kind name expected actual =
1223-- BAD ALIAS RECURSION
1222-- BAD ALIAS RECURSION
1224
1223
1225
1224
1226−aliasRecursionReport :: Code.Source -> R.Region -> Name.Name -> [Name.Name] -> Src.Type -> [Name.Name] -> Report.Report
1225+aliasRecursionReport :: Code.Source -> A.Region -> Name.Name -> [Name.Name] -> Src.Type -> [Name.Name] -> Report.Report
1227aliasRecursionReport source region name args tipe others =
1226aliasRecursionReport source region name args tipe others =
1228 case others of
1227 case others of
1229 [] ->
1228 [] ->
compiler/src/Reporting/Error/Docs.hs+16−16
@@ -9,22 +9,22 @@ module Reporting.Error.Docs
9
9
10import qualified Data.Name as Name
10import qualified Data.Name as Name
11
11
12+import qualified Reporting.Annotation as A
12import Reporting.Doc ((<>))
13import Reporting.Doc ((<>))
13import qualified Reporting.Doc as D
14import qualified Reporting.Doc as D
14−import qualified Reporting.Region as R
15import qualified Reporting.Render.Code as Code
15import qualified Reporting.Render.Code as Code
16import qualified Reporting.Report as Report
16import qualified Reporting.Report as Report
17
17
18
18
19
19
20data Error
20data Error
21− = NoDocs R.Region
21+ = NoDocs A.Region
22− | ImplicitExposing R.Region
22+ | ImplicitExposing A.Region
23− | Duplicate Name.Name R.Region R.Region
23+ | Duplicate Name.Name A.Region A.Region
24− | OnlyInDocs Name.Name R.Region
24+ | OnlyInDocs Name.Name A.Region
25− | OnlyInExports Name.Name R.Region
25+ | OnlyInExports Name.Name A.Region
26− | NoComment Name.Name R.Region
26+ | NoComment Name.Name A.Region
27− | NoAnnotation Name.Name R.Region
27+ | NoAnnotation Name.Name A.Region
28
28
29
29
30
30
@@ -66,14 +66,14 @@ toReport source err =
66 Report.toCodePair source r1 r2
66 Report.toCodePair source r1 r2
67 (
67 (
68 D.reflow $
68 D.reflow $
69− "There can only be one `" <> Name.toString name
69+ "There can only be one `" <> Name.toChars name
70 <> "` in your module documentation, but it is listed twice:"
70 <> "` in your module documentation, but it is listed twice:"
71 ,
71 ,
72 "Remove one of them!"
72 "Remove one of them!"
73 )
73 )
74 (
74 (
75 D.reflow $
75 D.reflow $
76− "There can only be one `" <> Name.toString name
76+ "There can only be one `" <> Name.toChars name
77 <> "` in your module documentation, but I see two. One here:"
77 <> "` in your module documentation, but I see two. One here:"
78 ,
78 ,
79 "And another one over here:"
79 "And another one over here:"
@@ -86,12 +86,12 @@ toReport source err =
86 Report.toCodeSnippet source region Nothing
86 Report.toCodeSnippet source region Nothing
87 (
87 (
88 D.reflow $
88 D.reflow $
89− "I do not see `" <> Name.toString name
89+ "I do not see `" <> Name.toChars name
90 <> "` in the `exposing` list, but it is in your module documentation:"
90 <> "` in the `exposing` list, but it is in your module documentation:"
91 ,
91 ,
92 D.reflow $
92 D.reflow $
93 "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 `"
94− <> Name.toString name <> "` and forgot to delete it here?"
94+ <> Name.toChars name <> "` and forgot to delete it here?"
95 )
95 )
96
96
97 OnlyInExports name region ->
97 OnlyInExports name region ->
@@ -99,12 +99,12 @@ toReport source err =
99 Report.toCodeSnippet source region Nothing
99 Report.toCodeSnippet source region Nothing
100 (
100 (
101 D.reflow $
101 D.reflow $
102− "I do not see `" <> Name.toString name
102+ "I do not see `" <> Name.toChars name
103 <> "` in your module documentation, but it is in your `exposing` list:"
103 <> "` in your module documentation, but it is in your `exposing` list:"
104 ,
104 ,
105 D.stack
105 D.stack
106 [ D.reflow $
106 [ D.reflow $
107− "Add a line like `@docs " <> Name.toString name
107+ "Add a line like `@docs " <> Name.toChars name
108 <> "` to your module documentation!"
108 <> "` to your module documentation!"
109 , 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."
110 ]
110 ]
@@ -115,7 +115,7 @@ toReport source err =
115 Report.toCodeSnippet source region Nothing
115 Report.toCodeSnippet source region Nothing
116 (
116 (
117 D.reflow $
117 D.reflow $
118− "The `" <> Name.toString name <> "` definition does not have a documentation comment."
118+ "The `" <> Name.toChars name <> "` definition does not have a documentation comment."
119 ,
119 ,
120 D.stack
120 D.stack
121 [ D.reflow $
121 [ D.reflow $
@@ -129,7 +129,7 @@ toReport source err =
129 Report.toCodeSnippet source region Nothing
129 Report.toCodeSnippet source region Nothing
130 (
130 (
131 D.reflow $
131 D.reflow $
132− "The `" <> Name.toString name <> "` definition does not have a type annotation."
132+ "The `" <> Name.toChars name <> "` definition does not have a type annotation."
133 ,
133 ,
134 D.stack
134 D.stack
135 [ D.reflow $
135 [ D.reflow $
compiler/src/Reporting/Error/Main.hs+6−6
@@ -10,9 +10,9 @@ module Reporting.Error.Main
10import qualified Data.Name as Name
10import qualified Data.Name as Name
11
11
12import qualified AST.Canonical as Can
12import qualified AST.Canonical as Can
13+import qualified Reporting.Annotation as A
13import qualified Reporting.Doc as D
14import qualified Reporting.Doc as D
14import qualified Reporting.Error.Canonicalize as E
15import qualified Reporting.Error.Canonicalize as E
15−import qualified Reporting.Region as R
16import qualified Reporting.Render.Code as Code
16import qualified Reporting.Render.Code as Code
17import qualified Reporting.Render.Type as RT
17import qualified Reporting.Render.Type as RT
18import qualified Reporting.Render.Type.Localizer as L
18import qualified Reporting.Render.Type.Localizer as L
@@ -24,9 +24,9 @@ import qualified Reporting.Report as Report
24
24
25
25
26data Error
26data Error
27− = BadType R.Region Can.Type
27+ = BadType A.Region Can.Type
28− | BadCycle R.Region [Name.Name]
28+ | BadCycle A.Region [Name.Name]
29− | BadFlags R.Region Can.Type E.InvalidPayload
29+ | BadFlags A.Region Can.Type E.InvalidPayload
30
30
31
31
32
32
@@ -101,14 +101,14 @@ toReport localizer source err =
101 "an unspecified type"
101 "an unspecified type"
102 ,
102 ,
103 D.reflow $
103 D.reflow $
104− "But type variables like `" ++ Name.toString name ++ "` cannot be given as flags.\
104+ "But type variables like `" ++ Name.toChars name ++ "` cannot be given as flags.\
105 \ 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\
106 \ unexpected data cannot sneak in and crash the Elm program."
106 \ unexpected data cannot sneak in and crash the Elm program."
107 )
107 )
108
108
109 E.UnsupportedType name ->
109 E.UnsupportedType name ->
110 (
110 (
111− "a `" ++ Name.toString name ++ "` value"
111+ "a `" ++ Name.toChars name ++ "` value"
112 ,
112 ,
113 D.stack
113 D.stack
114 [ 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/Type.hs+58−58
@@ -26,8 +26,8 @@ import qualified Data.Name as Name
26
26
27import qualified AST.Canonical as Can
27import qualified AST.Canonical as Can
28import qualified Data.Index as Index
28import qualified Data.Index as Index
29+import qualified Reporting.Annotation as A
29import qualified Reporting.Doc as D
30import qualified Reporting.Doc as D
30−import qualified Reporting.Region as R
31import qualified Reporting.Render.Code as Code
31import qualified Reporting.Render.Code as Code
32import qualified Reporting.Render.Type as RT
32import qualified Reporting.Render.Type as RT
33import qualified Reporting.Render.Type.Localizer as L
33import qualified Reporting.Render.Type.Localizer as L
@@ -41,9 +41,9 @@ import qualified Type.Error as T
41
41
42
42
43data Error
43data Error
44− = BadExpr R.Region Category T.Type (Expected T.Type)
44+ = BadExpr A.Region Category T.Type (Expected T.Type)
45− | BadPattern R.Region PCategory T.Type (PExpected T.Type)
45+ | BadPattern A.Region PCategory T.Type (PExpected T.Type)
46− | InfiniteType R.Region Name.Name T.Type
46+ | InfiniteType A.Region Name.Name T.Type
47
47
48
48
49
49
@@ -52,7 +52,7 @@ data Error
52
52
53data Expected tipe
53data Expected tipe
54 = NoExpectation tipe
54 = NoExpectation tipe
55− | FromContext R.Region Context tipe
55+ | FromContext A.Region Context tipe
56 | FromAnnotation Name.Name Int SubContext tipe
56 | FromAnnotation Name.Name Int SubContext tipe
57
57
58
58
@@ -66,7 +66,7 @@ data Context
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 Name.Name) R.Region Name.Name
69+ | RecordAccess A.Region (Maybe Name.Name) A.Region Name.Name
70 | RecordUpdateKeys Name.Name (Map.Map Name.Name Can.FieldUpdate)
70 | RecordUpdateKeys Name.Name (Map.Map Name.Name Can.FieldUpdate)
71 | RecordUpdateValue Name.Name
71 | RecordUpdateValue Name.Name
72 | Destructure
72 | Destructure
@@ -112,7 +112,7 @@ data Category
112
112
113data PExpected tipe
113data PExpected tipe
114 = PNoExpectation tipe
114 = PNoExpectation tipe
115− | PFromContext R.Region PContext tipe
115+ | PFromContext A.Region PContext tipe
116
116
117
117
118data PContext
118data PContext
@@ -183,7 +183,7 @@ toReport source localizer err =
183-- TO PATTERN REPORT
183-- TO PATTERN REPORT
184
184
185
185
186−toPatternReport :: Code.Source -> L.Localizer -> R.Region -> PCategory -> T.Type -> PExpected T.Type -> Report.Report
186+toPatternReport :: Code.Source -> L.Localizer -> A.Region -> PCategory -> T.Type -> PExpected T.Type -> Report.Report
187toPatternReport source localizer patternRegion category tipe expected =
187toPatternReport source localizer patternRegion category tipe expected =
188 Report.Report "TYPE MISMATCH" patternRegion [] $
188 Report.Report "TYPE MISMATCH" patternRegion [] $
189 case expected of
189 case expected of
@@ -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 `" <> Name.toString name <> "` is weird."
204+ "The " <> D.ordinal index <> " argument to `" <> Name.toChars 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 `" <> Name.toString name
207+ ( "But the type annotation on `" <> Name.toChars 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 `" <> Name.toString name <> "` is weird."
241+ "The " <> D.ordinal index <> " argument to `" <> Name.toChars 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 `" <> Name.toString name <> "` needs its "
244+ ( "But `" <> Name.toChars 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 -> " `" <> Name.toString name <> "` values of type:"
302+ PCtor name -> " `" <> Name.toChars 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 `" <> Name.toString name <> "` value is a:"
346+ Local name -> "This `" <> Name.toChars name <> "` value is a:"
347− Foreign name -> "This `" <> Name.toString name <> "` value is a:"
347+ Foreign name -> "This `" <> Name.toChars name <> "` value is a:"
348− Access field -> "The value at ." <> Name.toString field <> " is a:"
348+ Access field -> "The value at ." <> Name.toChars field <> " is a:"
349− Accessor field -> "This ." <> Name.toString field <> " field access function has type:"
349+ Accessor field -> "This ." <> Name.toChars 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 `" <> Name.toString name <> "` call produces:"
366+ FuncName name -> "This `" <> Name.toChars name <> "` call produces:"
367− CtorName name -> "This `" <> Name.toString name <> "` call produces:"
367+ CtorName name -> "This `" <> Name.toChars 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 `" ++ Name.toString n ++ "` value")
465+ T.Type _ n _ -> badRigidVar x ("a `" ++ Name.toChars 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 `" ++ Name.toString n ++ "` value")
469+ T.Alias _ n _ _ -> badRigidVar x ("a `" ++ Name.toChars 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 `" ++ Name.toString n ++ "` value")
480+ T.Type _ n _ -> badRigidSuper super ("a `" ++ Name.toChars 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 `" ++ Name.toString n ++ "` value")
484+ T.Alias _ n _ _ -> badRigidSuper super ("a `" ++ Name.toChars 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 (Name.toString typo) Name.toString possibilities of
502+ case Suggest.sort (Name.toChars typo) Name.toChars possibilities of
503 [] ->
503 [] ->
504 []
504 []
505
505
@@ -522,7 +522,7 @@ problemToHint problem =
522badRigidVar :: Name.Name -> String -> [D.Doc]
522badRigidVar :: Name.Name -> String -> [D.Doc]
523badRigidVar name aThing =
523badRigidVar name aThing =
524 [ D.toSimpleHint $
524 [ D.toSimpleHint $
525− "Your type annotation uses type variable `" ++ Name.toString name ++
525+ "Your type annotation uses type variable `" ++ Name.toChars 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?"
@@ -533,7 +533,7 @@ badRigidVar name aThing =
533badDoubleRigid :: Name.Name -> Name.Name -> [D.Doc]
533badDoubleRigid :: Name.Name -> Name.Name -> [D.Doc]
534badDoubleRigid x y =
534badDoubleRigid x y =
535 [ D.toSimpleHint $
535 [ D.toSimpleHint $
536− "Your type annotation uses `" ++ Name.toString x ++ "` and `" ++ Name.toString y ++
536+ "Your type annotation uses `" ++ Name.toChars x ++ "` and `" ++ Name.toChars y ++
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?"
@@ -625,7 +625,7 @@ badFlexFlexSuper s1 s2 =
625-- TO EXPR REPORT
625-- TO EXPR REPORT
626
626
627
627
628−toExprReport :: Code.Source -> L.Localizer -> R.Region -> Category -> T.Type -> Expected T.Type -> Report.Report
628+toExprReport :: Code.Source -> L.Localizer -> A.Region -> Category -> T.Type -> Expected T.Type -> Report.Report
629toExprReport source localizer exprRegion category tipe expected =
629toExprReport source localizer exprRegion category tipe expected =
630 case expected of
630 case expected of
631 NoExpectation expectedType ->
631 NoExpectation expectedType ->
@@ -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 `" <> Name.toString name <> "` definition:"
647+ TypedBody -> "body of the `" <> Name.toChars 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 `" <> Name.toString name <> "` says it should be:")
660+ ("But the type annotation on `" <> Name.toChars 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 `" <> Name.toString name <> "` value"
772+ FuncName name -> "The `" <> Name.toChars name <> "` value"
773− CtorName name -> "The `" <> Name.toString name <> "` value"
773+ CtorName name -> "The `" <> Name.toChars name <> "` value"
774− OpName op -> "The (" <> Name.toString op <> ") operator"
774+ OpName op -> "The (" <> Name.toChars 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 `" <> Name.toString name <> "` function"
785+ FuncName name -> "The `" <> Name.toChars name <> "` function"
786− CtorName name -> "The `" <> Name.toString name <> "` constructor"
786+ CtorName name -> "The `" <> Name.toChars name <> "` constructor"
787− OpName op -> "The (" <> Name.toString op <> ") operator"
787+ OpName op -> "The (" <> Name.toChars 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 -> "`" <> Name.toString name <> "`"
800+ FuncName name -> "`" <> Name.toChars name <> "`"
801− CtorName name -> "`" <> Name.toString name <> "`"
801+ CtorName name -> "`" <> Name.toChars name <> "`"
802− OpName op -> "(" <> Name.toString op <> ")"
802+ OpName op -> "(" <> Name.toChars 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 -> "`" <> Name.toString n <> "`") maybeName
826+ <> maybe "" (\n -> "`" <> Name.toChars n <> "`") maybeName
827− <> " record does not have a `" <> Name.toString field <> "` field:"
827+ <> " record does not have a `" <> Name.toChars field <> "` field:"
828− , case Suggest.sort (Name.toString field) (Name.toString . fst) (Map.toList fields) of
828+ , case Suggest.sort (Name.toChars field) (Name.toChars . 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 -> "`" <> Name.toString n <> "`") maybeName
836+ <> maybe "" (\n -> "`" <> Name.toChars 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 `" <> Name.toString record <> "` record is"
866+ , "The `" <> Name.toChars 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 = "`" <> Name.toString record <> "`"
877+ rStr = "`" <> Name.toChars record <> "`"
878− fStr = "`" <> Name.toString field <> "`"
878+ fStr = "`" <> Name.toChars 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 (Name.toString field) (Name.toString . fst) (Map.toList actualFields) of
883+ , case Suggest.sort (Name.toChars field) (Name.toChars . 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 `" <> Name.toString field <> "` field like this:"
911+ , "I cannot update the `" <> Name.toChars field <> "` field like this:"
912− , "You are trying to update `" <> Name.toString field <> "` to be"
912+ , "You are trying to update `" <> Name.toChars 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.\
@@ -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 (" <> Name.toString op <> ") is causing problems:"
1011+ "The left argument of (" <> Name.toChars 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 (" <> Name.toString op <> ") needs the left argument to be:")
1014+ ("But (" <> Name.toChars op <> ") needs the left argument to be:")
1015 []
1015 []
1016 )
1016 )
1017
1017
@@ -1103,12 +1103,12 @@ badOpRightFallback :: L.Localizer -> Category -> Name.Name -> T.Type -> T.Type -
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 (" <> Name.toString op <> ") is causing problems."
1106+ "The right argument of (" <> Name.toChars 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 (" <> Name.toString op <> ") needs the right argument to be:")
1109+ ("But (" <> Name.toChars op <> ") needs the right argument to be:")
1110 [ D.toSimpleHint $
1110 [ D.toSimpleHint $
1111− "With operators like (" ++ Name.toString op ++ ") I always check the left\
1111+ "With operators like (" ++ Name.toChars op ++ ") I always check the left\
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 ]
@@ -1318,7 +1318,7 @@ 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 (" <> Name.toString op <> ") to be the exact same type. Both Int or both Float."
1321+ "I need both sides of (" <> Name.toChars op <> ") to be the exact same type. Both Int or both Float."
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"]
@@ -1405,7 +1405,7 @@ badMath localizer category operation direction op tipe expected otherHints =
1405 loneType localizer tipe expected
1405 loneType localizer tipe expected
1406 (D.reflow (addCategory ("The " <> direction <> " side of (" <> op <> ") is") category))
1406 (D.reflow (addCategory ("The " <> direction <> " side of (" <> op <> ") is") category))
1407 ( [ D.fillSep
1407 ( [ D.fillSep
1408− ["But","(" <> D.fromString op <> ")","only","works","with"
1408+ ["But","(" <> D.fromChars op <> ")","only","works","with"
1409 ,D.dullyellow "Int","and",D.dullyellow "Float","values."
1409 ,D.dullyellow "Int","and",D.dullyellow "Float","values."
1410 ]
1410 ]
1411 ]
1411 ]
@@ -1513,7 +1513,7 @@ badCompLeft localizer category op direction tipe expected =
1513 loneType localizer tipe expected
1513 loneType localizer tipe expected
1514 (D.reflow (addCategory ("The " <> direction <> " side of (" <> op <> ") is") category))
1514 (D.reflow (addCategory ("The " <> direction <> " side of (" <> op <> ") is") category))
1515 [ D.fillSep
1515 [ D.fillSep
1516− ["But","(" <> D.fromString op <> ")","only","works","on"
1516+ ["But","(" <> D.fromChars op <> ")","only","works","on"
1517 ,D.dullyellow "Int" <> ","
1517 ,D.dullyellow "Int" <> ","
1518 ,D.dullyellow "Float" <> ","
1518 ,D.dullyellow "Float" <> ","
1519 ,D.dullyellow "Char" <> ","
1519 ,D.dullyellow "Char" <> ","
@@ -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 -> Name.Name -> T.Type -> Report.Report
1574+toInfiniteReport :: Code.Source -> L.Localizer -> A.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 " <> Name.toString name <> ":"
1580+ "I am inferring a weird self-referential type for " <> Name.toChars name <> ":"
1581 ,
1581 ,
1582 D.stack
1582 D.stack
1583 [ D.reflow $
1583 [ D.reflow $
compiler/src/Reporting/Render/Code.hs+32−39
@@ -11,11 +11,11 @@ module Reporting.Render.Code
11
11
12
12
13import qualified Data.List as List
13import qualified Data.List as List
14−import qualified Data.Text as Text
14+import Data.Word (Word16)
15
15
16−import Reporting.Doc (Doc, (<>))
16+import qualified Reporting.Annotation as A
17import qualified Reporting.Doc as D
17import qualified Reporting.Doc as D
18−import qualified Reporting.Region as R
18+import Reporting.Doc (Doc)
19
19
20
20
21
21
@@ -23,13 +23,13 @@ import qualified Reporting.Region as R
23
23
24
24
25newtype Source =
25newtype Source =
26− Source [(Int, Text.Text)]
26+ Source [(Word16, String)]
27
27
28
28
29−toSource :: Text.Text -> Source
29+toSource :: String -> Source
30toSource source =
30toSource source =
31 Source $ zip [1..] $
31 Source $ zip [1..] $
32− Text.lines source ++ [Text.empty]
32+ lines source ++ [""]
33
33
34
34
35
35
@@ -41,16 +41,13 @@ toSource source =
41 f a
41 f a
42
42
43
43
44−render :: Source -> R.Region -> Maybe R.Region -> Doc
44+render :: Source -> A.Region -> Maybe A.Region -> Doc
45−render (Source sourceLines) region@(R.Region start end) maybeSubRegion =
45+render (Source sourceLines) region@(A.Region (A.Position startLine _) (A.Position endLine _)) maybeSubRegion =
46 let
46 let
47− (R.Position startLine _) = start
48− (R.Position endLine _) = end
49−
50 relevantLines =
47 relevantLines =
51 sourceLines
48 sourceLines
52− |> drop (startLine - 1)
49+ |> drop (fromIntegral (startLine - 1))
53− |> take (1 + endLine - startLine)
50+ |> take (fromIntegral (1 + endLine - startLine))
54
51
55 width =
52 width =
56 length (show (fst (last relevantLines)))
53 length (show (fst (last relevantLines)))
@@ -66,40 +63,36 @@ render (Source sourceLines) region@(R.Region start end) maybeSubRegion =
66 drawLines False width smallerRegion relevantLines underline
63 drawLines False width smallerRegion relevantLines underline
67
64
68
65
69−makeUnderline :: Int -> Int -> R.Region -> Maybe Doc
66+makeUnderline :: Int -> Word16 -> A.Region -> Maybe Doc
70−makeUnderline width realEndLine (R.Region (R.Position start c1) (R.Position end c2)) =
67+makeUnderline width realEndLine (A.Region (A.Position start c1) (A.Position end c2)) =
71 if start /= end || end < realEndLine then
68 if start /= end || end < realEndLine then
72 Nothing
69 Nothing
73
70
74 else
71 else
75 let
72 let
76− spaces = replicate (c1 + width + 1) ' '
73+ spaces = replicate (fromIntegral c1 + width + 1) ' '
77− zigzag = replicate (max 1 (c2 - c1)) '^'
74+ zigzag = replicate (max 1 (fromIntegral (c2 - c1))) '^'
78 in
75 in
79− Just (D.fromString spaces <> D.dullred (D.fromString zigzag))
76+ Just (D.fromChars spaces <> D.dullred (D.fromChars zigzag))
80
77
81
78
82−drawLines :: Bool -> Int -> R.Region -> [(Int, Text.Text)] -> Doc -> Doc
79+drawLines :: Bool -> Int -> A.Region -> [(Word16, String)] -> Doc -> Doc
83−drawLines addZigZag width (R.Region start end) sourceLines finalLine =
80+drawLines addZigZag width (A.Region (A.Position startLine _) (A.Position endLine _)) sourceLines finalLine =
84− let
85− (R.Position startLine _) = start
86− (R.Position endLine _) = end
87− in
88 D.vcat $
81 D.vcat $
89 map (drawLine addZigZag width startLine endLine) sourceLines
82 map (drawLine addZigZag width startLine endLine) sourceLines
90 ++ [finalLine]
83 ++ [finalLine]
91
84
92
85
93−drawLine :: Bool -> Int -> Int -> Int -> (Int, Text.Text) -> Doc
86+drawLine :: Bool -> Int -> Word16 -> Word16 -> (Word16, String) -> Doc
94drawLine addZigZag width startLine endLine (n, line) =
87drawLine addZigZag width startLine endLine (n, line) =
95− addLineNumber addZigZag width startLine endLine n (D.fromText line)
88+ addLineNumber addZigZag width startLine endLine n (D.fromChars line)
96
89
97
90
98−addLineNumber :: Bool -> Int -> Int -> Int -> Int -> Doc -> Doc
91+addLineNumber :: Bool -> Int -> Word16 -> Word16 -> Word16 -> Doc -> Doc
99addLineNumber addZigZag width start end n line =
92addLineNumber addZigZag width start end n line =
100 let
93 let
101 number =
94 number =
102− if n < 0 then " " else show n
95+ show n
103
96
104 lineNumber =
97 lineNumber =
105 replicate (width - length number) ' ' ++ number ++ "|"
98 replicate (width - length number) ' ' ++ number ++ "|"
@@ -110,7 +103,7 @@ addLineNumber addZigZag width start end n line =
110 else
103 else
111 " "
104 " "
112 in
105 in
113− D.fromString lineNumber <> spacer <> line
106+ D.fromChars lineNumber <> spacer <> line
114
107
115
108
116
109
@@ -122,27 +115,27 @@ data CodePair
122 | TwoChunks Doc Doc
115 | TwoChunks Doc Doc
123
116
124
117
125−renderPair :: Source -> R.Region -> R.Region -> CodePair
118+renderPair :: Source -> A.Region -> A.Region -> CodePair
126renderPair source@(Source sourceLines) region1 region2 =
119renderPair source@(Source sourceLines) region1 region2 =
127 let
120 let
128− (R.Region (R.Position startRow1 startCol1) (R.Position endRow1 endCol1)) = region1
121+ (A.Region (A.Position startRow1 startCol1) (A.Position endRow1 endCol1)) = region1
129− (R.Region (R.Position startRow2 startCol2) (R.Position endRow2 endCol2)) = region2
122+ (A.Region (A.Position startRow2 startCol2) (A.Position endRow2 endCol2)) = region2
130 in
123 in
131 if startRow1 == endRow1 && endRow1 == startRow2 && startRow2 == endRow2 then
124 if startRow1 == endRow1 && endRow1 == startRow2 && startRow2 == endRow2 then
132 let
125 let
133 lineNumber = show startRow1
126 lineNumber = show startRow1
134− spaces1 = replicate (startCol1 + length lineNumber + 1) ' '
127+ spaces1 = replicate (fromIntegral startCol1 + length lineNumber + 1) ' '
135− zigzag1 = replicate (endCol1 - startCol1) '^'
128+ zigzag1 = replicate (fromIntegral (endCol1 - startCol1)) '^'
136− spaces2 = replicate (startCol2 - endCol1) ' '
129+ spaces2 = replicate (fromIntegral (startCol2 - endCol1)) ' '
137− zigzag2 = replicate (endCol2 - startCol2) '^'
130+ zigzag2 = replicate (fromIntegral (endCol2 - startCol2)) '^'
138
131
139 (Just line) = List.lookup startRow1 sourceLines
132 (Just line) = List.lookup startRow1 sourceLines
140 in
133 in
141 OneLine $
134 OneLine $
142 D.vcat
135 D.vcat
143− [ D.fromString lineNumber <> "| " <> D.fromText line
136+ [ D.fromChars lineNumber <> "| " <> D.fromChars line
144− , D.fromString spaces1 <> D.dullred (D.fromString zigzag1) <>
137+ , D.fromChars spaces1 <> D.dullred (D.fromChars zigzag1) <>
145− D.fromString spaces2 <> D.dullred (D.fromString zigzag2)
138+ D.fromChars spaces2 <> D.dullred (D.fromChars zigzag2)
146 ]
139 ]
147
140
148 else
141 else
compiler/src/Reporting/Render/Type/Localizer.hs+11−13
@@ -3,7 +3,7 @@
3module Reporting.Render.Type.Localizer
3module Reporting.Render.Type.Localizer
4 ( Localizer
4 ( Localizer
5 , toDoc
5 , toDoc
6− , toString
6+ , toChars
7 , empty
7 , empty
8 , fromNames
8 , fromNames
9 , fromModule
9 , fromModule
@@ -18,10 +18,8 @@ import qualified Data.Name as Name
18import qualified Data.Set as Set
18import qualified Data.Set as Set
19
19
20import qualified AST.Source as Src
20import qualified AST.Source as Src
21−import qualified AST.Valid as Valid
22import qualified Elm.Compiler.Imports as Imports
21import qualified Elm.Compiler.Imports as Imports
23import qualified Elm.ModuleName as ModuleName
22import qualified Elm.ModuleName as ModuleName
24−import qualified Elm.Package as Pkg
25import Reporting.Doc ((<>))
23import Reporting.Doc ((<>))
26import qualified Reporting.Doc as D
24import qualified Reporting.Doc as D
27import qualified Reporting.Annotation as A
25import qualified Reporting.Annotation as A
@@ -58,27 +56,27 @@ empty =
58
56
59toDoc :: Localizer -> ModuleName.Canonical -> Name.Name -> D.Doc
57toDoc :: Localizer -> ModuleName.Canonical -> Name.Name -> D.Doc
60toDoc localizer home name =
58toDoc localizer home name =
61− D.fromString (toString localizer home name)
59+ D.fromChars (toChars localizer home name)
62
60
63
61
64−toString :: Localizer -> ModuleName.Canonical -> Name.Name -> String
62+toChars :: Localizer -> ModuleName.Canonical -> Name.Name -> String
65−toString (Localizer localizer) moduleName@(ModuleName.Canonical _ home) name =
63+toChars (Localizer localizer) moduleName@(ModuleName.Canonical _ home) name =
66 case Map.lookup home localizer of
64 case Map.lookup home localizer of
67 Nothing ->
65 Nothing ->
68− Name.toString home <> "." <> Name.toString name
66+ Name.toChars home <> "." <> Name.toChars name
69
67
70 Just (Import alias exposing) ->
68 Just (Import alias exposing) ->
71 case exposing of
69 case exposing of
72 All ->
70 All ->
73− Name.toString name
71+ Name.toChars name
74
72
75 Only set ->
73 Only set ->
76 if Set.member name set then
74 if Set.member name set then
77− Name.toString name
75+ Name.toChars name
78 else if name == Name.list && moduleName == ModuleName.list then
76 else if name == Name.list && moduleName == ModuleName.list then
79 "List"
77 "List"
80 else
78 else
81− Name.toString (maybe home id alias) <> "." <> Name.toString name
79+ Name.toChars (maybe home id alias) <> "." <> Name.toChars name
82
80
83
81
84
82
@@ -94,8 +92,8 @@ fromNames names =
94-- FROM MODULE
92-- FROM MODULE
95
93
96
94
97−fromModule :: Valid.Module -> Localizer
95+fromModule :: Src.Module -> Localizer
98−fromModule (Valid.Module name _ _ _ imports _ _ _ _ _) =
96+fromModule (Src.Module name _ imports _ _ _ _ _) =
99 Localizer $ Map.fromList $
97 Localizer $ Map.fromList $
100 (name, Import Nothing All) : map toPair imports
98 (name, Import Nothing All) : map toPair imports
101
99
@@ -133,7 +131,7 @@ replEmpty :: Localizer
133replEmpty =
131replEmpty =
134 Localizer $
132 Localizer $
135 Map.insert Name.replModule (Import Nothing All) $
133 Map.insert Name.replModule (Import Nothing All) $
136− Map.fromList $ map toPair $ Imports.addDefaults Pkg.dummyName []
134+ Map.fromList $ map toPair $ Imports.addDefaults []
137
135
138
136
139replAdd :: Name.Name -> Maybe Name.Name -> Src.Exposing -> Localizer -> Localizer
137replAdd :: Name.Name -> Maybe Name.Name -> Src.Exposing -> Localizer -> Localizer
compiler/src/Reporting/Report.hs+5−5
@@ -8,8 +8,8 @@ module Reporting.Report
8 where
8 where
9
9
10
10
11+import qualified Reporting.Annotation as A
11import qualified Reporting.Doc as D
12import qualified Reporting.Doc as D
12−import qualified Reporting.Region as R
13import qualified Reporting.Render.Code as Code
13import qualified Reporting.Render.Code as Code
14
14
15
15
@@ -20,7 +20,7 @@ import qualified Reporting.Render.Code as Code
20data Report =
20data Report =
21 Report
21 Report
22 { _title :: String
22 { _title :: String
23− , _region :: R.Region
23+ , _region :: A.Region
24 , _sgstns :: [String]
24 , _sgstns :: [String]
25 , _message :: D.Doc
25 , _message :: D.Doc
26 }
26 }
@@ -42,7 +42,7 @@ messageBar title filePath =
42 usedSpace =
42 usedSpace =
43 4 + length title + 1 + length filePath
43 4 + length title + 1 + length filePath
44 in
44 in
45− D.dullcyan $ D.fromString $
45+ D.dullcyan $ D.fromChars $
46 "-- " ++ title
46 "-- " ++ title
47 ++ " " ++ replicate (max 1 (80 - usedSpace)) '-'
47 ++ " " ++ replicate (max 1 (80 - usedSpace)) '-'
48 ++ " " ++ filePath
48 ++ " " ++ filePath
@@ -52,7 +52,7 @@ messageBar title filePath =
52-- CODE FORMATTING
52-- CODE FORMATTING
53
53
54
54
55−toCodeSnippet :: Code.Source -> R.Region -> Maybe R.Region -> (D.Doc, D.Doc) -> D.Doc
55+toCodeSnippet :: Code.Source -> A.Region -> Maybe A.Region -> (D.Doc, D.Doc) -> D.Doc
56toCodeSnippet source region highlight (preHint, postHint) =
56toCodeSnippet source region highlight (preHint, postHint) =
57 D.vcat
57 D.vcat
58 [ preHint
58 [ preHint
@@ -62,7 +62,7 @@ toCodeSnippet source region highlight (preHint, postHint) =
62 ]
62 ]
63
63
64
64
65−toCodePair :: Code.Source -> R.Region -> R.Region -> (D.Doc, D.Doc) -> (D.Doc, D.Doc, D.Doc) -> D.Doc
65+toCodePair :: Code.Source -> A.Region -> A.Region -> (D.Doc, D.Doc) -> (D.Doc, D.Doc, D.Doc) -> D.Doc
66toCodePair source r1 r2 (oneStart, oneEnd) (twoStart, twoMiddle, twoEnd) =
66toCodePair source r1 r2 (oneStart, oneEnd) (twoStart, twoMiddle, twoEnd) =
67 case Code.renderPair source r1 r2 of
67 case Code.renderPair source r1 r2 of
68 Code.OneLine codeDocs ->
68 Code.OneLine codeDocs ->
compiler/src/Reporting/Warning.hs+10−10
@@ -13,8 +13,8 @@ import qualified Data.Name as Name
13
13
14import qualified AST.Canonical as Can
14import qualified AST.Canonical as Can
15import qualified AST.Utils.Type as Type
15import qualified AST.Utils.Type as Type
16+import qualified Reporting.Annotation as A
16import qualified Reporting.Doc as D
17import qualified Reporting.Doc as D
17−import qualified Reporting.Region as R
18import qualified Reporting.Report as Report
18import qualified Reporting.Report as Report
19import qualified Reporting.Render.Code as Code
19import qualified Reporting.Render.Code as Code
20import qualified Reporting.Render.Type as RT
20import qualified Reporting.Render.Type as RT
@@ -26,9 +26,9 @@ import qualified Reporting.Render.Type.Localizer as L
26
26
27
27
28data Warning
28data Warning
29− = UnusedImport R.Region Name.Name
29+ = UnusedImport A.Region Name.Name
30− | UnusedVariable R.Region Context Name.Name
30+ | UnusedVariable A.Region Context Name.Name
31− | MissingTypeAnnotation R.Region Name.Name Can.Type
31+ | MissingTypeAnnotation A.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 `" <> Name.toString moduleName <> "` module is used in this file."
49+ "Nothing from the `" <> Name.toChars 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 `" <> Name.toString name <> "` anywhere."
60+ "You are not using `" <> Name.toChars 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 `" <> Name.toString name
64+ "Is there a typo? Maybe you intended to use `" <> Name.toChars 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 `" <> Name.toString name
71+ ( "If you are sure there is no typo, replace `" <> Name.toChars 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 `" <> Name.toString name <> "` function has no type annotation."
84+ "The `" <> Name.toChars name <> "` function has no type annotation."
85
85
86 _ ->
86 _ ->
87− "The `" <> Name.toString name <> "` definition has no type annotation."
87+ "The `" <> Name.toChars 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:"
compiler/src/Type/Error.hs+3−3
@@ -282,7 +282,7 @@ toDiff localizer ctx tipe1 tipe2 =
282
282
283 -- start trying to find specific problems
283 -- start trying to find specific problems
284
284
285− (Type home1 name1 args1, Type home2 name2 args2) | L.toString localizer home1 name1 == L.toString localizer home2 name2 ->
285+ (Type home1 name1 args1, Type home2 name2 args2) | L.toChars localizer home1 name1 == L.toChars localizer home2 name2 ->
286 different
286 different
287 (nameClashToDoc ctx localizer home1 name1 args1)
287 (nameClashToDoc ctx localizer home1 name1 args1)
288 (nameClashToDoc ctx localizer home2 name2 args2)
288 (nameClashToDoc ctx localizer home2 name2 args2)
@@ -307,7 +307,7 @@ toDiff localizer ctx tipe1 tipe2 =
307
307
308 Nothing ->
308 Nothing ->
309 case t2 of
309 case t2 of
310− Type home2 name2 args2 | L.toString localizer home1 name1 == L.toString localizer home2 name2 ->
310+ Type home2 name2 args2 | L.toChars localizer home1 name1 == L.toChars localizer home2 name2 ->
311 different
311 different
312 (nameClashToDoc ctx localizer home1 name1 (map snd args1))
312 (nameClashToDoc ctx localizer home1 name1 (map snd args1))
313 (nameClashToDoc ctx localizer home2 name2 args2)
313 (nameClashToDoc ctx localizer home2 name2 args2)
@@ -326,7 +326,7 @@ toDiff localizer ctx tipe1 tipe2 =
326
326
327 Nothing ->
327 Nothing ->
328 case t1 of
328 case t1 of
329− Type home1 name1 args1 | L.toString localizer home1 name1 == L.toString localizer home2 name2 ->
329+ Type home1 name1 args1 | L.toChars localizer home1 name1 == L.toChars localizer home2 name2 ->
330 different
330 different
331 (nameClashToDoc ctx localizer home1 name1 args1)
331 (nameClashToDoc ctx localizer home1 name1 args1)
332 (nameClashToDoc ctx localizer home2 name2 (map snd args2))
332 (nameClashToDoc ctx localizer home2 name2 (map snd args2))