Similar to MonadStateOf, but σ is an outParam for convenience.
Instance Constructor
MonadState.mk.{u, v}
Methods
get : m σ
(← get) : σ gets the state out of a monad m.
set : σ → m PUnit
set (s : σ) replaces the state with value s.
modifyGet : {α : Type u} → (σ → α × σ) → m α
modifyGet (f : σ → α × σ) applies f to the current state, replaces
the state with the return value, and returns a computed value.
It is equivalent to do let (a, s) := f (← get); put s; pure a, but
modifyGet f may be preferable because the former does not use the state
linearly (without sufficient inlining).