Module Monads.Std.Monad.Cont

module Cont: sig .. end
The continuation monad.

The continuation monad reifies computations by making them available as first class values. A continuation encapsulates an evaluation context of a host language (OCaml in our case). The continuation monad behaves like it is a function monad, except that it provides the call/cc operator. The call/cc operator calls a user provided function with a current continuaton. This continuation can be stored in a state (i.e., if the Continuation monad is composed with the State monad) and later resumed. It may also be used to implement various control structures, i.e., exceptions or coroutines.

The same as with the state monad we provide two interfaces, one with the type of final result of the computation is fixed on the module level, and another where it is a type variable.


module type S = sig .. end
The unary monad interface
module type S2 = sig .. end
The binary monad interface.
type ('a, 'r) cont 
type of continuation monads
include Monads.Std.Monad.Cont.S2
module T1 (T : Std.T)  (M : Std.Monad.Monad) : sig .. end
module T2 (M : Std.Monad.Monad) : sig .. end
module Make (T : Std.T)  (M : Std.Monad.Monad) : S 
        with type 'a t := 'a T1(T)(M).t
         and type 'a m := 'a T1(T)(M).m
         and type 'a e := 'a T1(T)(M).e
         and type r := T.t
Make(T)(M) wraps the monad M into the continuation monad and fix the type of the whole computation to T.t
module Make2 (M : Std.Monad.Monad) : S2 
        with type ('a,'e) t := ('a,'e) T2(M).t
         and type 'a m     := 'a     T2(M).m
         and type ('a,'e) e := ('a,'e) T2(M).e
Make2(M) wrapes the monad M into the continuation monad.