module Cf_cmonad: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.
type('x, 'a)
t =('a -> 'x) -> 'x
module Op:sig
..end
( >>= )
binding operator for composition of
continuation monads.
val nil : ('x, unit) t
unit
and performs no operation.val return : 'a -> ('x, 'a) t
return a
to produce a monad that returns a
as an intermediate
result from the current continuation.val init : 'x -> ('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) -> ('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 eval : ('x, unit) t -> 'x -> 'x
eval m
to evaluate the continuation monad to produce a function from
initial continuation context to final continuation context.