State.Core_over_monad
module M : Preface_specs.MONAD
module State : Preface_specs.Types.T0
type state = State.t
The encapsulated state.
type 'a monad = 'a M.t
The inner monad.
type 'a t = state -> ('a * state) monad
The type held by the state monad.
val upper : 'a monad -> 'a t
promote monad into the transformation.
val eval : 'a t -> state -> 'a monad
Unwrap the state computation and extract the current value.
val exec : 'a t -> state -> state monad
Unwrap the state computation and extract the current state.
val run : 'a t -> state -> ('a * state) monad
Unwrap the state computation.
val state : (state -> 'a * state) -> 'a t
Lift a function into a state.
val get : state t
Returns the current state.
val set : state -> unit t
Replace the state with the given one.
val modify : (state -> state) -> unit t
Modify the state applying the given function.
val gets : (state -> 'a) -> 'a t
Apply a function to the current state and return it.