Travesty.State_transform
Haskell-style state transformers.
State transformers generalise state monads. They attach onto an existing monad, and allow the stateful computations to return and handle values inside that monad. For example, transforming On_error
provides stateful, potentially-failing computations.
We provide two signatures for state transformers: one corresponding to the situation where the state type is fixed at the module level (S), and one leaving the state type as part of the monad type (S2
). Both have corresponding make functors.
We also provide a functor To_S
for fixing the state type in an arity-2 monad after the fact.
For input and output signatures for this module's functors, see State_transform_types
.
module To_S
(M : State_transform_types.S2)
(B : Base.T) :
State_transform_types.S
with type state = B.t
and type 'a t = ('a, B.t) M.t
and module Inner = M.Inner
module Make
(B : State_transform_types.Basic) :
State_transform_types.S with type state = B.t and module Inner = B.Inner