Recall that StateRefT
is a macro that infers ω
from the m
.
Executes an action from a monad with added state in the underlying monad m
. Given an initial
state, it returns a value paired with the final state.
The monad m
must support ST
effects in order to create and mutate reference cells.
Equations
Instances For
Executes an action from a monad with added state in the underlying monad m
. Given an initial
state, it returns a value, discarding the final state.
The monad m
must support ST
effects in order to create and mutate reference cells.
Equations
Instances For
Runs an action from the underlying monad in the monad with state. The state is not modified.
This function is typically implicitly accessed via a MonadLiftT
instance as part of automatic
lifting.
Equations
Instances For
Equations
Equations
Equations
Equations
Retrieves the current value of the monad's mutable state.
This increments the reference count of the state, which may inhibit in-place updates.
Equations
Instances For
Replaces the mutable state with a new value.
Equations
Instances For
Applies a function to the current state that both computes a new state and a value. The new state replaces the current state, and the value is returned.
It is equivalent to a get
followed by a set
. However, using modifyGet
may lead to higher
performance because it doesn't add a new reference to the state value. Additional references can
inhibit in-place updates of data.