It's a very common pattern in an Elm-architecture app that you
want to say, "call this sub-update function to get a (submodel,
subeffects) pair, then merge the submodel into the main model with
this record update, and the subeffects into the main effects by
applying this wrapping function.
This function wraps that step up, so this example code:
case action of
LoginAction x -> let (newLoginModel, newLoginEffect) = Login.update x model.loginModel
in ({model | loginModel <- newLoginModel}
,Effects.map LoginAction newLoginEffect)
...becomes:
case action of
LoginAction x -> liftUpdate (Login.update x model.loginModel)
((\v m -> { m | loginModel <- v}), LoginAction)
(model, none)
It's a very common pattern in an Elm-architecture app that you want to say, "call this sub-update function to get a (submodel, subeffects) pair, then merge the submodel into the main model with this record update, and the subeffects into the main effects by applying this wrapping function.
This function wraps that step up, so this example code:
...becomes: