State package:relude

A state monad parameterized by the type s of the state to carry. The return function leaves the state unchanged, while >>= uses the final state of the first computation as the initial state of the second.
Embed a simple state action into the monad.
A state transformer monad parameterized by:
  • s - The state.
  • m - The inner monad.
The return function leaves the state unchanged, while >>= uses the final state of the first computation as the initial state of the second.
Minimal definition is either both of get and put or just state
Evaluate a state computation with the given initial state and return the final value, discarding the final state.
Evaluate a state computation with the given initial state and return the final value, discarding the final state.
Evaluate a state computation with the given initial state and return the final state, discarding the final value.
Evaluate a state computation with the given initial state and return the final state, discarding the final value.
Unwrap a state monad computation as a function. (The inverse of state.)
withState f m executes action m on a state modified by applying f.
Alias for flip evalState. It's not shorter but sometimes more readable. Done by analogy with using* functions family.
Alias for flip evalStateT. It's not shorter but sometimes more readable. Done by analogy with using* functions family.
Alias for flip execState. It's not shorter but sometimes more readable. Done by analogy with using* functions family.
Alias for flip execStateT. It's not shorter but sometimes more readable. Done by analogy with using* functions family.
Shorter and more readable alias for flip runState.
Shorter and more readable alias for flip runStateT.
>>> usingStateT 0 $ put 42 >> pure False
(False,42)