Computations which maintain state.
Binding strategy: Binding threads a state parameter through the sequence of bound functions so that the same state value is never used twice, giving the illusion of in-place update.
Useful for: Building computations from sequences of operations that require a shared state.
State
return : a -> State s a
return function for State
bind : State s a -> (a -> State s b) -> State s b
bind function for State
runState : State s a -> s -> ( a, s )
Run the state
get : State a a
Get current state
put : s -> State s ()
Put a new state
evalState : State s a -> s -> a
Get the new value
execState : State s a -> s -> s
Get the new state