@@ -90,7 +90,7 @@ validateEffects tag settings@(A.A _ pairs) decls =
9090 foldr collectSettings Map.empty pairs
9191 in
9292 do managerType <- toManagerType tagRegion settingsDict
93− (r0, r1, r2) <- getManagerRegions tagRegion Nothing Nothing Nothing decls
93+ (r0, r1, r2) <- checkManagerImpl tagRegion managerType noInfo decls
9494 return (Fx.Effect (Fx.Info tagRegion r0 r1 r2 managerType))
9595
9696
@@ -166,34 +166,58 @@ extractOne name settingsDict =
166166-- EFFECT REGIONS
167167
168168
169−getManagerRegions
169+data ManagerInfo =
170+ ManagerInfo
171+ { _cmdMap :: Bool
172+ , _subMap :: Bool
173+ , _init :: Maybe R.Region
174+ , _onEffects :: Maybe R.Region
175+ , _onSelfMsg :: Maybe R.Region
176+ }
177+
178+
179+noInfo :: ManagerInfo
180+noInfo =
181+ ManagerInfo False False Nothing Nothing Nothing
182+
183+
184+checkManagerImpl
170185 :: R.Region
171− -> Maybe R.Region
172− -> Maybe R.Region
173− -> Maybe R.Region
186+ -> Fx.ManagerType
187+ -> ManagerInfo
174188 -> [D.Valid]
175189 -> Result.Result w Error.Error (R.Region, R.Region, R.Region)
176−getManagerRegions tagRegion r0 r1 r2 decls =
190+checkManagerImpl tagRegion managerType info decls =
177191 case decls of
178192 [] ->
179− (,,)
180− <$> requireRegion tagRegion "init" r0
181− <*> requireRegion tagRegion "onEffects" r1
182− <*> requireRegion tagRegion "onSelfMsg" r2
193+ let
194+ (ManagerInfo cmdMap subMap init onEffects onSelfMsg) = info
195+ in
196+ const (,,)
197+ <$> requireMaps tagRegion managerType cmdMap subMap
198+ <*> requireRegion tagRegion "init" init
199+ <*> requireRegion tagRegion "onEffects" onEffects
200+ <*> requireRegion tagRegion "onSelfMsg" onSelfMsg
183201
184202 decl : rest ->
185203 case getDefInfo decl of
186204 Just ("init", region) ->
187− getManagerRegions tagRegion (Just region) r1 r2 rest
205+ checkManagerImpl tagRegion managerType (info { _init = Just region }) rest
188206
189207 Just ("onEffects", region) ->
190− getManagerRegions tagRegion r0 (Just region) r2 rest
208+ checkManagerImpl tagRegion managerType (info { _onEffects = Just region }) rest
191209
192210 Just ("onSelfMsg", region) ->
193− getManagerRegions tagRegion r0 r1 (Just region) rest
211+ checkManagerImpl tagRegion managerType (info { _onSelfMsg = Just region }) rest
212+
213+ Just ("cmdMap", _) ->
214+ checkManagerImpl tagRegion managerType (info { _cmdMap = True }) rest
215+
216+ Just ("subMap", _) ->
217+ checkManagerImpl tagRegion managerType (info { _subMap = True }) rest
194218
195219 _ ->
196− getManagerRegions tagRegion r0 r1 r2 rest
220+ checkManagerImpl tagRegion managerType info rest
197221
198222
199223getDefInfo :: D.Valid -> Maybe (String, R.Region)
@@ -206,6 +230,25 @@ getDefInfo decl =
206230 Nothing
207231
208232
233+requireMaps :: R.Region -> Fx.ManagerType -> Bool -> Bool -> Result.Result w Error.Error ()
234+requireMaps tagRegion managerType hasCmdMap hasSubMap =
235+ let
236+ check hasIt name =
237+ when (not hasIt) (Result.throw tagRegion (Error.MissingManagerOnEffectModule name))
238+ in
239+ case managerType of
240+ Fx.CmdManager _ ->
241+ check hasCmdMap "cmdMap"
242+
243+ Fx.SubManager _ ->
244+ check hasSubMap "subMap"
245+
246+ Fx.FxManager _ _ ->
247+ (\_ _ -> ())
248+ <$> check hasCmdMap "cmdMap"
249+ <*> check hasSubMap "subMap"
250+
251+
209252requireRegion :: R.Region -> String -> Maybe R.Region -> Result.Result w Error.Error R.Region
210253requireRegion tagRegion name maybeRegion =
211254 case maybeRegion of