State Monad

State monad contains a function that is performed on some context to produce some value, as well as some new context:

State Monad
1
2
3
data State ContextType ValueType =
State (ContextType -> (ValueType, ContextType))
-- Indeed, State monad uses the constructor `state`