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

Module Effect.Deep

module Deep: sig .. end


Deep handlers

type ('a, 'b) continuation = ('a, 'b) continuation

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

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

continue k x resumes the continuation k by passing x to k.

val discontinue : ('a, 'b) [continuation](Effect.Deep.html#TYPEcontinuation) -> exn -> 'b

discontinue k e resumes the continuation k by raising the exception e in k.

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

discontinue_with_backtrace k e bt resumes the continuation k by raising the exception e in k using bt as the origin for the exception.

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 match_with : ('c -> 'a) -> 'c -> ('a, 'b) [handler](Effect.Deep.html#TYPEhandler) -> 'b

match_with f v h runs the computation f v in the handler h.

type 'a effect_handler = {

}

'a effect_handler is a deep handler with an identity value handlerfun x -> x and an exception handler that raises any exceptionfun e -> raise e.

val try_with : ('b -> 'a) -> 'b -> 'a [effect_handler](Effect.Deep.html#TYPEeffect%5Fhandler) -> 'a

try_with f v h runs the computation f v under the handler h.

val get_callstack : ('a, 'b) [continuation](Effect.Deep.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.