This module provides a monadic interface for commands.
Basically CmdM is like Cmd but is a monad, which means
you can chain effects as you like!
This module port the four main way of running an Elm application to CmdM.
Program using IO.
Port of Platform.program with IO.
Port of VirtualDom.program with CmdM (also works with HTML).
Port of Platform.programWithFlags with CmdM.
Port of VirtualDom.programWithFlags with CmdM (also works with Html).
Returns a CmdM whose only effect is containing the value given to pure.
Transforms an Elm command into a monadic command CmdM.
A CmdM doing nothing (an containing no values!).
Map a function over an CmdM.
Laws
map (f >> g) = (map f) >> (map g)map identity = identityChains CmdMs.
If you have a CmdM a and a function which given
a a can give you a CmdM b depending on the value
of type a given to the function. Then bind gives you
a CmdM b that will run the first CmdM and then apply
the function.
Laws
bind pure = identitybind (f >> pure) = map f(bind f) >> (bind g) = bind (a -> bind g (f a))Flatten a CmdM containing a CmdM into a simple CmdM.
Laws
join (pure m) = mTransform a CmdM containing functions into functions on CmdM. It enable to easily lift functions to CmdM.
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 CmdM effects over a list.
Transform a list of CmdM into an CmdM of list.
Transform a program using IO into a normal program.
Transform a program using CmdM into a normal program.
If you need to convert CmdM to something else, this is the way.
Catamorphism for CmdM. Strict version.
Catamorphism for CmdM. Lazy version.
Group commands in a batch. Its behavior may not be what you expect! I strongly discourage you from using it. Use mapM instead.
Group commands in a batch. Its behavior may not be what you expect! I strongly discourage you from using it. Use mapM instead.
Monadic interface for commands.
A value of type
CmdM msgis an effectful computation that can perform commands and contains values of typemsg.