Rerouted (regenerated, verified). Same repository and tag, but GitHub now builds the zip with different bytes, so it no longer matches the SHA-1 package.elm-lang.org recorded. The Lamdera package server serves a copy recovered from https://github.com/arowM/elm-update-builder.
What we checked: Rebuilt with git archive from commit bc34dda88992 of https://github.com/arowM/elm-update-builder (zip prefix arowM-elm-update-builder-28038c2/, America/Los_Angeles times, the tag object 28038c2c789a it had before it was re-made, tagger time 2021-04-28 18:30 UTC): the zip is byte-identical to the one package.elm-lang.org recorded, SHA-1 e183cfd21ec99d17f062179f996aa34b6f6bf2b7.
The Lamdera compiler uses this copy and prints a one-line notice saying so. elm itself fails to download this version.
Details · package.elm-lang.org's zip: https://github.com/arowM/elm-update-builder/zipball/1.1.1/
Module providing a way to build scalable update function. It enables you to build a complex update function by composing primitive functions.
Evaluate to a model-cmd pair.
It is for converting to the normal update function. e.g.,
main : Program flags model msg
main =
element
{ init = init
, view = view
, update = Update.run << update
, subscriptions = subscriptions
}
update : msg -> Update model msg
update =
...When you need to evaluate a couple Updates, you can batch them together. Each is evaluated from top to bottom.
type alias Model = { foo : String }
myUpdate : Update Model msg
myUpdate =
batch
[ modify (\m -> { m | foo = m.foo ++ "-1" })
, modify (\m -> { m | foo = m.foo ++ "-2" })
]
run myUpdate { foo = "bar" }
|> Tuple.first
--> { foo = "bar-1-2" }Evaluate Update only if it meets the condition.
Evaluate Update unless it meets the condition.
Evaluate Update only if the first argument value is Nothing.
Evaluate Update only if the first argument value is Just.
Evaluate Update only if the first argument value is Ok.
Evaluate Update only if the first argument value is Err.
Branch the update process according to the situation.
type alias Model =
{ foo : String
, bar : Maybe Int
}
updateWithFoo : Update Model msg
updateWithFoo =
with .foo
[ on String.isEmpty
[ Update.modify <| \model ->
{ model | foo = "empty" }
]
]
updateWithBar : Update Model msg
updateWithBar =
with .bar
[ onJust
[ \n -> Update.modify <| \model ->
{ model | foo = String.fromInt n }
]
]
updateWithBarSequentially : Update Model msg
updateWithBarSequentially =
with .bar
[ onJust
[ \n -> Update.modify <| \model ->
{ model | bar = Nothing }
]
, onNothing
[ Update.modify <| \model ->
{ model | foo = "bar has changed" }
]
]
run updateWithFoo
{ foo = ""
, bar = Nothing
}
|> Tuple.first
--> { foo = "empty", bar = Nothing }
run updateWithFoo
{ foo = "foo"
, bar = Nothing
}
|> Tuple.first
--> { foo = "foo", bar = Nothing }
run updateWithBar
{ foo = "foo"
, bar = Just 4
}
|> Tuple.first
--> { foo = "4", bar = Just 4 }
run updateWithBarSequentially
{ foo = "foo"
, bar = Just 4
}
|> Tuple.first
--> { foo = "bar has changed", bar = Nothing }Evaluate Update only if it matches the case.
Evaluate Update only if the case is Nothing.
Evaluate Update only if the case is Just.
Evaluate Update only if the case is Ok.
Evaluate Update only if the case is Err.
Lift Update for a child model to one for the parent model.
e.g.,
type alias Model =
{ child1 : ChildModel
}
type alias ChildModel =
{ foo : String
}
child1Update : Update ChildModel msg
child1Update =
Debug.todo "Update for the `ChildModel`"
update : Update Model msg
update =
child
.child1
(\c model -> { model | child1 = c })
child1UpdateSame as child but do nothing if first argument becomes to Nothing.
It is usefull for handling page updates of SPA.
e.g.,
type alias Model =
{ page : Page
}
type Page
= Page1 Page1Model
| Page2 Page2Model
type alias Page1Model =
{ foo : String
}
type alias Page2Model =
{ bar : Int
}
page1Update : Update Page1Model msg
page1Update =
Debug.todo "update function for `Page1`."
update : Update Model msg
update =
Update.with identity
[ \{ page } ->
case page of
Page1 page1 ->
page1Update
(\model ->
case model.page of
Page1 a ->
Just a
_ ->
Nothing
)
(\p model ->
case model.page of
Page1 _ ->
{ model | page = Page1 p }
_ ->
model
)
page1Update
_ ->
Debug.todo ""
]
Alternative type for update function.