This module provides a monadic interface for The Elm Architecture.
Basically IO is a monad enabing two kinds of effects :
Transform a sandbox program using IO into a normal sandbox program.
Transform an element program using IO into a normal element program.
Transform a document program using IO into a normal document program.
Transform an application program using IO into a normal application program.
Lift a classic update function into an IO.
Chains IOs.
If you have an IO model a and a function which given a a can give you an IO model b depending on the value of type a given to the function. Then andThen gives you an IO model b that will run the first IO and then apply the function.
Laws
andThen pure = identityandThen (f >> pure) = map f(andThen f) >> (andThen g) = andThen (a -> andThen g (f a))Flipped version of ap. To be used like:
pure f |> flap arg1 |> flap arg2 ...Composition of monadic functions
Run the second argument, ignore the result, then run the first one. To be used in
first |> seq secondCongruence by a Lens on an IO.
It would be silly to force users to redefine every IO for each application model. Lenses enable to lift an IO action on a model a to the same IO but action on a model b.
You can then define your IO on the minimal model and lift them to you real application's model when needed.
Replace get and set by custom functions
Dummy update function.
Dummy subscription function
Identity function that forces Elm to render the current state. Is equivalent to sleep for 0 milliseconds.
Forces Elm to render every set operation (model update). This is MUCH SLOWER than normal set operations.
Transform a program using IO into a normal program.
Beware that batch operations might not do what you think. The execution order of messages and commands is not defined.
Send messages in batch mode
Monadic interface for The Elm Architecture.
A value of type
IO model ais an effectful computation that can modify the modelmodel, perform commands and contains values of typea.