module Cf_scmonad:sig
..end
The state-continuation monad is provided here purely for reference
purposes. It may be helpful as an example of how to lift the continuation
monad into more complex monads.
type('s, 'x, 'a)
t =('s -> 'x, 'a) Cf_cmonad.t
module Op:sig
..end
val nil : ('s, 'x, unit) t
unit
and performs no operation.val return : 'a -> ('s, 'x, 'a) t
return a
to produce a monad that returns a
as an intermediate
result from the current continuation.val init : 'x -> ('s, 'x, 'a) t
init x
to produce a monad that discards the current intermediate
result and returns x
as the continuation context.val cont : ('x -> 'x) -> ('s, 'x, unit) t
cont f
to produce a monad that passes the calling continuation to
the function f
and returns the unit value as an intermediate result.val load : ('s, 'x, 's) t
val store : 's -> ('s, 'x, unit) t
store s
to produce a monad with s
as the value of its encapsulated
state.val modify : ('s -> 's) -> ('s, 'x, unit) t
modify f
to produce a monad that applies f
to the encapsulated
state to obtain a new state value, and which returns the unit value as its
intermediate result.val field : ('s -> 'a) -> ('s, 'x, 'a) t
field f
to produce a monad that returns the result of applying f
to
the value of the encapsulated state.val down : ('s, 'x, unit) t -> 's -> ('x, 's) Cf_cmonad.t
down m s
to produce a stateless continuation monad from a
state-continuation monad and an initial state.val lift : ('x, 'a) Cf_cmonad.t -> ('s, 'x, 'a) t
lift m
to lift a stateless continuation monad into a
state-continuation monad.