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) tunit and performs no operation.val return : 'a -> ('s, 'x, 'a) treturn a to produce a monad that returns a as an intermediate
result from the current continuation.val init : 'x -> ('s, 'x, 'a) tinit 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) tcont 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) tval store : 's -> ('s, 'x, unit) tstore s to produce a monad with s as the value of its encapsulated
state.val modify : ('s -> 's) -> ('s, 'x, unit) tmodify 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) tfield 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.tdown 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) tlift m to lift a stateless continuation monad into a
state-continuation monad.