on master help sign in
Get rid of a bunch of TODOs in error messages
04c5e28Evan Czaplicki
src/Canonicalize/Effects.hs+1−1
@@ -73,7 +73,7 @@ figureOutKind region name rootType =
73 <* checkPortType (makeError region name) incomingType
73 <* checkPortType (makeError region name) incomingType
74
74
75 _ ->
75 _ ->
76− Result.throw region (error "TODO - bad overall type")
76+ Result.throw region (Error.BadPort name rootType)
77
77
78
78
79makeError :: R.Region -> String -> T.Canonical -> Maybe String -> A.Located Error.Error
79makeError :: R.Region -> String -> T.Canonical -> Maybe String -> A.Located Error.Error
src/Reporting/Error/Canonicalize.hs+19
@@ -23,6 +23,7 @@ data Error
23 | Export String [String]
23 | Export String [String]
24 | DuplicateExport String
24 | DuplicateExport String
25 | Port PortError
25 | Port PortError
26+ | BadPort String Type.Canonical
26
27
27
28
28
29
@@ -242,6 +243,21 @@ toReport localizer err =
242 ]
243 ]
243 )
244 )
244
245
246+ BadPort name tipe ->
247+ Report.report
248+ "PORT ERROR"
249+ Nothing
250+ ("Port `" ++ name ++ "` has an invalid type."
251+ )
252+ ( Help.stack
253+ [ text ("You are saying it should be:")
254+ , indent 4 (RenderType.toDoc localizer tipe)
255+ , Help.reflowParagraph $
256+ "But you need to use the particular format described here:\
257+ \ <http://guide.elm-lang.org/effect_managers/>"
258+ ]
259+ )
260+
245
261
246argMismatchReport :: String -> Var.Canonical -> Int -> Int -> Report.Report
262argMismatchReport :: String -> Var.Canonical -> Int -> Int -> Report.Report
247argMismatchReport kind var expected actual =
263argMismatchReport kind var expected actual =
@@ -288,6 +304,9 @@ extractSuggestions err =
288 Port _ ->
304 Port _ ->
289 Nothing
305 Nothing
290
306
307+ BadPort _ _ ->
308+ Nothing
309+
291
310
292unsafePromote :: Type.Raw -> Type.Canonical
311unsafePromote :: Type.Raw -> Type.Canonical
293unsafePromote (A.A _ rawType) =
312unsafePromote (A.A _ rawType) =
src/Reporting/Error/Syntax.hs+2−2
@@ -135,7 +135,7 @@ toReport _localizer err =
135 "If you just wanted a normal module, change the keywords `effect module`\
135 "If you just wanted a normal module, change the keywords `effect module`\
136 \ to `module` and you should be all set. If you want a proper effect module,\
136 \ to `module` and you should be all set. If you want a proper effect module,\
137 \ you need to specify your commands and/or subscriptions. Read more about this\
137 \ you need to specify your commands and/or subscriptions. Read more about this\
138− \ here: <TODO> (please forgive me if I forgot to fill this in!)"
138+ \ here: <http://guide.elm-lang.org/effect_managers/>"
139 )
139 )
140
140
141 MissingManagerOnEffectModule name ->
141 MissingManagerOnEffectModule name ->
@@ -147,7 +147,7 @@ toReport _localizer err =
147 "There is a small set of top-level functions and values that must be defined\
147 "There is a small set of top-level functions and values that must be defined\
148 \ in any complete effect module. The best thing is probably to just read more\
148 \ in any complete effect module. The best thing is probably to just read more\
149 \ about effect modules here:\
149 \ about effect modules here:\
150− \ <TODO> (please forgive me if I forgot to fill this in!)"
150+ \ <http://guide.elm-lang.org/effect_managers/>"
151 )
151 )
152
152
153 UnexpectedPort name ->
153 UnexpectedPort name ->
src/Reporting/Error/Type.hs+6−5
@@ -458,7 +458,8 @@ mismatchToReport localizer (MismatchInfo hint leftType rightType maybeReason) =
458 ( cmpHint
458 ( cmpHint
459 ("Your `" ++ name ++ "` function has this type:")
459 ("Your `" ++ name ++ "` function has this type:")
460 "But it needs to have a type like this:"
460 "But it needs to have a type like this:"
461− [ "TODO - link to overview of effect managers"
461+ [ "You can read more about setting up effect managers properly here:\
462+ \ <http://guide.elm-lang.org/effect_managers/>"
462 ]
463 ]
463 )
464 )
464
465
@@ -471,8 +472,8 @@ mismatchToReport localizer (MismatchInfo hint leftType rightType maybeReason) =
471 ( cmpHint
472 ( cmpHint
472 "The state created by `init` has this type:"
473 "The state created by `init` has this type:"
473 ("But `" ++ name ++ "` expects state of this type:")
474 ("But `" ++ name ++ "` expects state of this type:")
474− [ "Make the two state types match and you should be all set!"
475+ [ "Make the two state types match and you should be all set! More info here:\
475− , "TODO - link to overview of effect managers"
476+ \ <http://guide.elm-lang.org/effect_managers/>"
476 ]
477 ]
477 )
478 )
478
479
@@ -483,8 +484,8 @@ mismatchToReport localizer (MismatchInfo hint leftType rightType maybeReason) =
483 ( cmpHint
484 ( cmpHint
484 "The `onEffects` function can send this type of message:"
485 "The `onEffects` function can send this type of message:"
485 "But the `onSelfMsg` function receives this type:"
486 "But the `onSelfMsg` function receives this type:"
486− [ "Make the two message types match and you should be all set!"
487+ [ "Make the two message types match and you should be all set! More info here:\
487− , "TODO - link to overview of effect managers"
488+ \ <http://guide.elm-lang.org/effect_managers/>"
488 ]
489 ]
489 )
490 )
490
491