module Cf_cmonad:The continuation monad and its operators.sig..end
A continuation monad represents a computation composed of stages that can be interrupted, resumed and rescheduled. Because Objective Caml is an eager language programming in the continuation-passing style (CPS) can be simplified by the use of the continuation monad and its operators.
Note: see the Cf_gadget module for an example of its use.
Types
type('a, 'b)t =('b -> 'a) -> 'a
module Op:sig..end
( >>= ) binding operator for composition of
continuation monads.
val nil : ('a, unit) tunit and performs no operation.val return : 'a -> ('b, 'a) treturn a to produce a monad that returns a as an intermediate
result from the current continuation.val init : 'a -> ('a, 'b) tinit x to produce a monad that discards the current intermediate
result and returns x as the continuation context.val cont : ('a -> 'a) -> ('a, 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 eval : ('a, unit) t -> 'a -> 'aeval m to evaluate the continuation monad to produce a function from
initial continuation context to final continuation context.