on master help sign in
Get rid of a couple TODO's related to error reporting for effect modules
commit0d58dee8c8ce7b4825c36ae4c5e98e26e469a890 authorEvan Czaplicki <info@elm-lang.org> dateSun 6 Mar 2016, 17:21 (11 years ago) parent2d33116
4 files changed+26−10
src/Reporting/Error/Syntax.hs+16−3 src/Reporting/Error/Type.hs+7−4 src/Type/Constrain/Expression.hs+2−2 src/Validate.hs+1−1
src/Reporting/Error/Syntax.hs+16−3
@@ -25,6 +25,7 @@ data Error
2525 | DuplicateSettingOnEffectModule String
2626 | BadSettingOnEffectModule String
2727 | NoSettingsOnEffectModule
28+ | MissingManagerOnEffectModule String
2829
2930 | InfixDuplicate String
3031 | TypeWithoutDefinition String
@@ -105,15 +106,24 @@ toReport _localizer err =
105106 Report.report
106107 "BAD MODULE DECLARATION"
107108 Nothing
108− "A normal module can expose values, but not register commands and subscriptions."
109+ "A normal module can expose values, but not settings like this."
109110 ( Help.reflowParagraph $
110111 "If you want a normal module, just remove this stuff. If you want to create\
111112 \ an `effect module` you just forgot to use the `effect` keyword. In that\
112− \ case, just change `module` to `effect module` and you should be all set!"
113+ \ case, just change `module` to `effect module` and you should be headed in\
114+ \ the right direction!"
113115 )
114116
115117 SettingsOnForeignModule ->
116− error "TODO - SettingsOnForeignModule"
118+ Report.report
119+ "BAD MODULE DECLARATION"
120+ Nothing
121+ "A foreign effect module can expose values, but not have settings like this."
122+ ( Help.reflowParagraph $
123+ "If you want a foreign effect module, just remove this stuff. If you want\
124+ \ to create an `effect module` instead, just change `foreign effect module`\
125+ \ to `effect module` and you should be headed in the right direction!"
126+ )
117127
118128 DuplicateSettingOnEffectModule name ->
119129 error "TODO - DuplicateSettingOnEffectModule" name
@@ -124,6 +134,9 @@ toReport _localizer err =
124134 NoSettingsOnEffectModule ->
125135 error "TODO - NoSettingsOnEffectModule"
126136
137+ MissingManagerOnEffectModule name ->
138+ error "TODO - NoSettingsOnEffectModule" name
139+
127140 InfixDuplicate opName ->
128141 Report.report
129142 "INFIX OVERLAP"
src/Reporting/Error/Type.hs+7−4
@@ -436,7 +436,8 @@ mismatchToReport localizer (MismatchInfo hint leftType rightType maybeReason) =
436436 ( cmpHint
437437 ("Your `" ++ name ++ "` function has this type:")
438438 "But it needs to have a type like this:"
439− []
439+ [ "TODO - link to overview of effect managers"
440+ ]
440441 )
441442
442443 State name ->
@@ -447,8 +448,9 @@ mismatchToReport localizer (MismatchInfo hint leftType rightType maybeReason) =
447448 )
448449 ( cmpHint
449450 "The state created by `init` has this type:"
450− ("But the state updated by `" ++ name ++ "` has this type:")
451− [ "Just get the state to be the same type in both functions and you should be all set!"
451+ ("But `" ++ name ++ "` expects state of this type:")
452+ [ "Make the two state types match and you should be all set!"
453+ , "TODO - link to overview of effect managers"
452454 ]
453455 )
454456
@@ -459,7 +461,8 @@ mismatchToReport localizer (MismatchInfo hint leftType rightType maybeReason) =
459461 ( cmpHint
460462 "The `onEffects` function can send this type of message:"
461463 "But the `onSelfMsg` function receives this type:"
462− [ "Just get the message type to be the same in both functions and you should be all set!"
464+ [ "Make the two message types match and you should be all set!"
465+ , "TODO - link to overview of effect managers"
463466 ]
464467 )
465468
src/Type/Constrain/Expression.hs+2−2
@@ -40,12 +40,12 @@ constrain env annotatedExpr@(A.A region expression) tipe =
4040 E.Cmd moduleName typeName ->
4141 do (vars, cmd) <-
4242 Env.instantiateType env (ST.cmd moduleName typeName) Map.empty
43− return $ ex vars (CEqual (error "TODO - Cmd") region cmd tipe)
43+ return $ ex vars (CEqual (Error.Instance "command") region cmd tipe)
4444
4545 E.Sub moduleName typeName ->
4646 do (vars, sub) <-
4747 Env.instantiateType env (ST.sub moduleName typeName) Map.empty
48− return $ ex vars (CEqual (error "TODO - Sub") region sub tipe)
48+ return $ ex vars (CEqual (Error.Instance "subscription") region sub tipe)
4949
5050 E.SaveEnv moduleName effects ->
5151 Effects.constrain env moduleName effects
src/Validate.hs+1−1
@@ -213,7 +213,7 @@ requireRegion tagRegion name maybeRegion =
213213 return region
214214
215215 Nothing ->
216− Result.throw tagRegion (error $ "TODO - " ++ name)
216+ Result.throw tagRegion (Error.MissingManagerOnEffectModule name)
217217
218218
219219