module Cf_scmonad:The state-continuation monad and its operators.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.
Types
type('a, 'b, 'c)
t =('a -> 'b, 'c) Cf_cmonad.t
module Op:sig
..end
val nil : ('a, 'b, unit) t
unit
and performs no operation.val return : 'a -> ('b, 'c, 'a) t
return a
to produce a monad that returns a
as an intermediate
result from the current continuation.val init : 'a -> ('b, 'a, 'c) t
init x
to produce a monad that discards the current intermediate
result and returns x
as the continuation context.val cont : ('a -> 'a) -> ('b, 'a, 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 : ('a, 'b, 'a) t
val store : 'a -> ('a, 'b, unit) t
store s
to produce a monad with s
as the value of its encapsulated
state.val modify : ('a -> 'a) -> ('a, 'b, 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 : ('a -> 'b) -> ('a, 'c, 'b) t
field f
to produce a monad that returns the result of applying f
to
the value of the encapsulated state.val down : ('a, 'b, unit) t -> 'a -> ('b, 'a) Cf_cmonad.t
down m s
to produce a stateless continuation monad from a
state-continuation monad and an initial state.val lift : ('a, 'b) Cf_cmonad.t -> ('c, 'a, 'b) t
lift m
to lift a stateless continuation monad into a
state-continuation monad.