General workflow-management
module Flow exposing (Flow(..), map, withDefault, mapDefault, view, update) | |
import Html | |
type Flow state | |
= NotRunning | |
| Running state | |
map : (state -> state') -> Flow state -> Flow state' | |
map f flow = | |
case flow of | |
NotRunning -> | |
NotRunning | |
Running state -> | |
Running <| f state | |
withDefault : state -> Flow state -> state | |
withDefault default flow = | |
case flow of | |
NotRunning -> | |
default | |
Running state -> | |
state | |
mapDefault : state' -> (state -> state') -> Flow state -> state' | |
mapDefault default fn flow = | |
map fn flow | |
|> withDefault default | |
view : (state -> Html.Html msg) -> Flow state -> Html.Html msg | |
view viewFn flow = | |
mapDefault (Html.text "") viewFn flow | |
update : (state -> ( Flow state, Cmd msg )) -> Flow state -> ( Flow state, Cmd msg) | |
update fn flow = | |
mapDefault ( flow, Cmd.none ) fn flow |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This comment has been minimized.
Nice, but what is the Irn module?