OCaml library : Effect.Shallow (original) (raw)

Module Effect.Shallow

module Shallow: sig .. end


type ('a, 'b) continuation

('a,'b) continuation is a delimited continuation that expects a 'a value and returns a 'b value.

val fiber : ('a -> 'b) -> ('a, 'b) [continuation](Effect.Shallow.html#TYPEcontinuation)

fiber f constructs a continuation that runs the computation f.

type ('a, 'b) handler = {

}

('a,'b) handler is a handler record with three fields -- retc is the value handler, exnc handles exceptions, and effc handles the effects performed by the computation enclosed by the handler.

val continue_with : ('c, 'a) [continuation](Effect.Shallow.html#TYPEcontinuation) -> 'c -> ('a, 'b) [handler](Effect.Shallow.html#TYPEhandler) -> 'b

continue_with k v h resumes the continuation k with value v with the handler h.

val discontinue_with : ('c, 'a) [continuation](Effect.Shallow.html#TYPEcontinuation) -> exn -> ('a, 'b) [handler](Effect.Shallow.html#TYPEhandler) -> 'b

discontinue_with k e h resumes the continuation k by raising the exception e with the handler h.

val discontinue_with_backtrace : ('a, 'b) [continuation](Effect.Shallow.html#TYPEcontinuation) -> exn -> [Printexc.raw_backtrace](Printexc.html#TYPEraw%5Fbacktrace) -> ('b, 'c) [handler](Effect.Shallow.html#TYPEhandler) -> 'c

discontinue_with k e bt h resumes the continuation k by raising the exception e with the handler h using the raw backtrace bt as the origin of the exception.

val get_callstack : ('a, 'b) [continuation](Effect.Shallow.html#TYPEcontinuation) -> int -> [Printexc.raw_backtrace](Printexc.html#TYPEraw%5Fbacktrace)

get_callstack c n returns a description of the top of the call stack on the continuation c, with at most n entries.