module Cf_cmonad:sig..end
The continuation monad and its operators.
The continuation monad is provided here mostly for reference purposes, since it is helpful to refer to it when lifting into a more complex monad.
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
The continuation monad: a function for passing intermediate results from continuation context to continuation context.
module Op:sig..end
A module containing the ( >>= ) binding operator for composition of
continuation monads.
val nil : ('x, unit) tA monad that returns unit and performs no operation.
val return : 'a -> ('x, 'a) tUse return a to produce a monad that returns a as an intermediate
result from the current continuation.
val init : 'x -> ('x, 'a) tUse 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) tUse 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 -> 'xUse eval m to evaluate the continuation monad to produce a function from
initial continuation context to final continuation context.