on master help sign in
Get rid of a couple TODO's related to error reporting for effect modules
0d58deeEvan Czaplicki
src/Reporting/Error/Syntax.hs+16−3
@@ -25,6 +25,7 @@ data Error
25 | DuplicateSettingOnEffectModule String
25 | DuplicateSettingOnEffectModule String
26 | BadSettingOnEffectModule String
26 | BadSettingOnEffectModule String
27 | NoSettingsOnEffectModule
27 | NoSettingsOnEffectModule
28+ | MissingManagerOnEffectModule String
28
29
29 | InfixDuplicate String
30 | InfixDuplicate String
30 | TypeWithoutDefinition String
31 | TypeWithoutDefinition String
@@ -105,15 +106,24 @@ toReport _localizer err =
105 Report.report
106 Report.report
106 "BAD MODULE DECLARATION"
107 "BAD MODULE DECLARATION"
107 Nothing
108 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."
109 ( Help.reflowParagraph $
110 ( Help.reflowParagraph $
110 "If you want a normal module, just remove this stuff. If you want to create\
111 "If you want a normal module, just remove this stuff. If you want to create\
111 \ an `effect module` you just forgot to use the `effect` keyword. In that\
112 \ 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!"
113 )
115 )
114
116
115 SettingsOnForeignModule ->
117 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+ )
117
127
118 DuplicateSettingOnEffectModule name ->
128 DuplicateSettingOnEffectModule name ->
119 error "TODO - DuplicateSettingOnEffectModule" name
129 error "TODO - DuplicateSettingOnEffectModule" name
@@ -124,6 +134,9 @@ toReport _localizer err =
124 NoSettingsOnEffectModule ->
134 NoSettingsOnEffectModule ->
125 error "TODO - NoSettingsOnEffectModule"
135 error "TODO - NoSettingsOnEffectModule"
126
136
137+ MissingManagerOnEffectModule name ->
138+ error "TODO - NoSettingsOnEffectModule" name
139+
127 InfixDuplicate opName ->
140 InfixDuplicate opName ->
128 Report.report
141 Report.report
129 "INFIX OVERLAP"
142 "INFIX OVERLAP"
src/Reporting/Error/Type.hs+7−4
@@ -436,7 +436,8 @@ mismatchToReport localizer (MismatchInfo hint leftType rightType maybeReason) =
436 ( cmpHint
436 ( cmpHint
437 ("Your `" ++ name ++ "` function has this type:")
437 ("Your `" ++ name ++ "` function has this type:")
438 "But it needs to have a type like this:"
438 "But it needs to have a type like this:"
439+ [ "TODO - link to overview of effect managers"
439− []
440+ ]
440 )
441 )
441
442
442 State name ->
443 State name ->
@@ -447,8 +448,9 @@ mismatchToReport localizer (MismatchInfo hint leftType rightType maybeReason) =
447 )
448 )
448 ( cmpHint
449 ( cmpHint
449 "The state created by `init` has this type:"
450 "The state created by `init` has this type:"
450− ("But the state updated by `" ++ name ++ "` has this type:")
451+ ("But `" ++ name ++ "` expects state of this type:")
451− [ "Just get the state to be the same type in both functions and you should be all set!"
452+ [ "Make the two state types match and you should be all set!"
453+ , "TODO - link to overview of effect managers"
452 ]
454 ]
453 )
455 )
454
456
@@ -459,7 +461,8 @@ mismatchToReport localizer (MismatchInfo hint leftType rightType maybeReason) =
459 ( cmpHint
461 ( cmpHint
460 "The `onEffects` function can send this type of message:"
462 "The `onEffects` function can send this type of message:"
461 "But the `onSelfMsg` function receives this type:"
463 "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"
463 ]
466 ]
464 )
467 )
465
468
src/Type/Constrain/Expression.hs+2−2
@@ -40,12 +40,12 @@ constrain env annotatedExpr@(A.A region expression) tipe =
40 E.Cmd moduleName typeName ->
40 E.Cmd moduleName typeName ->
41 do (vars, cmd) <-
41 do (vars, cmd) <-
42 Env.instantiateType env (ST.cmd moduleName typeName) Map.empty
42 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)
44
44
45 E.Sub moduleName typeName ->
45 E.Sub moduleName typeName ->
46 do (vars, sub) <-
46 do (vars, sub) <-
47 Env.instantiateType env (ST.sub moduleName typeName) Map.empty
47 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)
49
49
50 E.SaveEnv moduleName effects ->
50 E.SaveEnv moduleName effects ->
51 Effects.constrain env moduleName effects
51 Effects.constrain env moduleName effects
src/Validate.hs+1−1
@@ -213,7 +213,7 @@ requireRegion tagRegion name maybeRegion =
213 return region
213 return region
214
214
215 Nothing ->
215 Nothing ->
216− Result.throw tagRegion (error $ "TODO - " ++ name)
216+ Result.throw tagRegion (Error.MissingManagerOnEffectModule name)
217
217
218
218
219
219