Skip to content

Commit

Permalink
Get rid of a bunch of TODOs in error messages
Browse files Browse the repository at this point in the history
  • Loading branch information
process-bot committed Apr 26, 2016
1 parent ec69a6c commit 04c5e28
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/Canonicalize/Effects.hs
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ figureOutKind region name rootType =
<* checkPortType (makeError region name) incomingType

_ ->
Result.throw region (error "TODO - bad overall type")
Result.throw region (Error.BadPort name rootType)


makeError :: R.Region -> String -> T.Canonical -> Maybe String -> A.Located Error.Error
Expand Down
19 changes: 19 additions & 0 deletions src/Reporting/Error/Canonicalize.hs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ data Error
| Export String [String]
| DuplicateExport String
| Port PortError
| BadPort String Type.Canonical



Expand Down Expand Up @@ -242,6 +243,21 @@ toReport localizer err =
]
)

BadPort name tipe ->
Report.report
"PORT ERROR"
Nothing
("Port `" ++ name ++ "` has an invalid type."
)
( Help.stack
[ text ("You are saying it should be:")
, indent 4 (RenderType.toDoc localizer tipe)
, Help.reflowParagraph $
"But you need to use the particular format described here:\
\ <http://guide.elm-lang.org/effect_managers/>"
]
)


argMismatchReport :: String -> Var.Canonical -> Int -> Int -> Report.Report
argMismatchReport kind var expected actual =
Expand Down Expand Up @@ -288,6 +304,9 @@ extractSuggestions err =
Port _ ->
Nothing

BadPort _ _ ->
Nothing


unsafePromote :: Type.Raw -> Type.Canonical
unsafePromote (A.A _ rawType) =
Expand Down
4 changes: 2 additions & 2 deletions src/Reporting/Error/Syntax.hs
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ toReport _localizer err =
"If you just wanted a normal module, change the keywords `effect module`\
\ to `module` and you should be all set. If you want a proper effect module,\
\ you need to specify your commands and/or subscriptions. Read more about this\
\ here: <TODO> (please forgive me if I forgot to fill this in!)"
\ here: <http://guide.elm-lang.org/effect_managers/>"
)

MissingManagerOnEffectModule name ->
Expand All @@ -147,7 +147,7 @@ toReport _localizer err =
"There is a small set of top-level functions and values that must be defined\
\ in any complete effect module. The best thing is probably to just read more\
\ about effect modules here:\
\ <TODO> (please forgive me if I forgot to fill this in!)"
\ <http://guide.elm-lang.org/effect_managers/>"
)

UnexpectedPort name ->
Expand Down
11 changes: 6 additions & 5 deletions src/Reporting/Error/Type.hs
Original file line number Diff line number Diff line change
Expand Up @@ -458,7 +458,8 @@ mismatchToReport localizer (MismatchInfo hint leftType rightType maybeReason) =
( cmpHint
("Your `" ++ name ++ "` function has this type:")
"But it needs to have a type like this:"
[ "TODO - link to overview of effect managers"
[ "You can read more about setting up effect managers properly here:\
\ <http://guide.elm-lang.org/effect_managers/>"
]
)

Expand All @@ -471,8 +472,8 @@ mismatchToReport localizer (MismatchInfo hint leftType rightType maybeReason) =
( cmpHint
"The state created by `init` has this type:"
("But `" ++ name ++ "` expects state of this type:")
[ "Make the two state types match and you should be all set!"
, "TODO - link to overview of effect managers"
[ "Make the two state types match and you should be all set! More info here:\
\ <http://guide.elm-lang.org/effect_managers/>"
]
)

Expand All @@ -483,8 +484,8 @@ mismatchToReport localizer (MismatchInfo hint leftType rightType maybeReason) =
( cmpHint
"The `onEffects` function can send this type of message:"
"But the `onSelfMsg` function receives this type:"
[ "Make the two message types match and you should be all set!"
, "TODO - link to overview of effect managers"
[ "Make the two message types match and you should be all set! More info here:\
\ <http://guide.elm-lang.org/effect_managers/>"
]
)

Expand Down

0 comments on commit 04c5e28

Please sign in to comment.