Get the current state.
$$\text{get} : \text{StateT}\ \sigma\ m\ \sigma$$
Equations
Instances For
Replace the state with a new value.
$$\text{put}(\sigma) : \text{StateT}\ \sigma\ m\ \text{Unit}$$
Equations
Instances For
Modify the state by applying a function.
$$\text{modify}(f) : \text{StateT}\ \sigma\ m\ \text{Unit}$$
Equations
- Control.Monad.State.modify f = StateT.modifyGet fun (s : σ) => ((), f s)
Instances For
Get a projection of the current state.
$$\text{gets}(f) = f \circ \text{get}$$
Equivalent to f <$> get.
Equations
- Control.Monad.State.gets f = do let s ← StateT.get pure (f s)
Instances For
Run a StateT computation with an initial state.
$$\text{runStateT}(ma, s_0) : m\ (\alpha \times \sigma)$$
Alias for StateT.run.
Equations
- Control.Monad.State.runStateT ma s = ma.run s
Instances For
Run a StateT computation, returning only the final value.
$$\text{evalStateT}(ma, s_0) : m\ \alpha$$
Equations
- Control.Monad.State.evalStateT ma s = Prod.fst <$> ma.run s
Instances For
Run a StateT computation, returning only the final state.
$$\text{execStateT}(ma, s_0) : m\ \sigma$$
Equations
- Control.Monad.State.execStateT ma s = Prod.snd <$> ma.run s
Instances For
Run a pure State computation with an initial state.
$$\text{runState}(ma, s_0) : \alpha \times \sigma$$
Equations
- Control.Monad.State.runState ma s = StateT.run ma s
Instances For
Run a pure State computation, returning only the final value.
$$\text{evalState}(ma, s_0) : \alpha$$
Equations
- Control.Monad.State.evalState ma s = (StateT.run ma s).fst
Instances For
Run a pure State computation, returning only the final state.
$$\text{execState}(ma, s_0) : \sigma$$
Equations
- Control.Monad.State.execState ma s = (StateT.run ma s).snd