This module provides a monadic interface for The Elm Architecture.
Basically IO is a monad enabing two kinds of effects :
This module port the four main way of running an Elm application to IO.
Program using IO.
Port of Platform.program with IO.
Port of VirtualDom.program with IO (also works with Html).
Port of Platform.programWithFlags with IO.
Port of VirtualDom.programWithFlags with IO (also works with Html).
Returns an IO whose only effect is containing the value given to pure.
Lift a Cmd as an IO.
Lift a CmdM as an IO.
Lift a classic update function into an IO.
An IO doing nothing (an containing no values!).
An IO that returns the current model.
An IO that sets the model.
A IO that modify the model.
Map a function over an IO.
Laws
map (f >> g) = (map f) >> (map g)map identity = identityChains 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 bind gives you an IO model b that will run the first IO and then apply the function.
Laws
bind pure = identitybind (f >> pure) = map f(bind f) >> (bind g) = bind (a -> bind g (f a))Flatten an IO containing an IO into a simple IO.
Laws
join (pure m) = mTransform an IO containing functions into functions on IO It enable to easily lift functions to IO.
Laws
ap (pure identity) = identityap (pure (f >> g)) = ap (pure f) >> ap (pure g)You can think of traverse like a map but with effects. It maps a function performing IO effects over a list.
Transform a list of IO into an IO of list.
Congruence 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.
Congruence by a Select on an IO. Just like lenses but with Select.
Transform a program using IO into a normal program.
Transform a program using IO into a normal program.
Combine a list of IO. Its use is strongly discouraged! Use mapM instead!
Combine two IO. Its use is strongly discouraged! Use *mapM instead!
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.