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.
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.
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
- StateRefT'.lift x x✝ = x
Instances For
Equations
- StateRefT'.instMonad = inferInstanceAs (Monad (ReaderT (ST.Ref ω σ) m))
Equations
- StateRefT'.instMonadLift = { monadLift := fun {α : Type} => StateRefT'.lift }
Equations
- StateRefT'.instMonadFunctor σ m = inferInstanceAs (MonadFunctor m (ReaderT (ST.Ref ω σ) m))
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
- StateRefT'.get ref = ref.get
Instances For
Replaces the mutable state with a new value.
Equations
- StateRefT'.set s ref = ref.set s
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.
Equations
- StateRefT'.modifyGet f ref = ref.modifyGet f
Instances For
Equations
- StateRefT'.instMonadStateOfOfMonadLiftTST = { get := StateRefT'.get, set := StateRefT'.set, modifyGet := fun {α : Type} => StateRefT'.modifyGet }
Equations
- One or more equations did not get rendered due to their size.
Equations
- instMonadControlStateRefT' ω σ m = inferInstanceAs (MonadControl m (ReaderT (ST.Ref ω σ) m))
Equations
- instMonadFinallyStateRefT' = inferInstanceAs (MonadFinally (ReaderT (ST.Ref ω σ) m))