updateSeparately: (a -> m -> m) -> (a -> ( m, m ) -> Effects a) -> a -> m -> ( m, Effects a )
StartApp apps supply an update function of:
update : Action -> Model -> ( Model, Effects a)
As apps grow larger, and more nested, this complection of Model and
Effects results becomes a real pain to manage. The wiring for
calling a sub-component's update function, upacking the result pair,
and re-packing into your own result pair, is very tedious.
Things become much cleaner if we split the effects out. First, we retype update as:
update : Action -> Model -> Model
update action model = ...
StartApp apps supply an update function of:
As apps grow larger, and more nested, this complection of
ModelandEffectsresults becomes a real pain to manage. The wiring for calling a sub-component'supdatefunction, upacking the result pair, and re-packing into your own result pair, is very tedious.Things become much cleaner if we split the effects out. First, we retype
updateas:...then we supply a separate
effectsfunction of:(Often your
effectsfunction will just usenewModel, but you may need access to the model beforeupdatewas called.)This separation of concerns cleans up each function, reduces wiring and makes testing a bit easier too.
To use it, split your functions as above, then in your
StartApp.startcall use: