Effect.Shallow(3)
β¨ NAME β¨
omg hi bestie π welcome to the Effect.Shallow(3) page. The official NAME section is literally βno descriptionβ β iconic, mysterious, zero notes. But itβs all about shallow effect handlers and delimited continuations, and weβre gonna get you comfy with it. π¦
π§© Module π§©
Module Effect.Shallow
π Documentation π
π§ Module Shallow
Module Shallow
: sig end
Okay so hereβs the whole Shallow module vibe β itβs giving βsmall but powerful,β and every type and val below is exactly whatβs on the menu. π
type ('a, 'b) continuationβ bestie, this is a delimited continuation that expects a'avalue and returns a'bvalue. lowkey main character energy: itβs waiting for a value, then it gives you a result. πval fiber : ('a -> 'b) -> ('a, 'b) continuationβfiber fconstructs a continuation that runs the computationf. slay. β¨type ('a, 'b) handler = { ... }β this is the handler record with three fields. not me being obsessed with a record, but here we are:
type ('a, 'b) handler = {
retc : 'a -> 'b ;
exnc : exn -> 'b ;
effc : 'c. 'c Effect.t -> (('c, 'a) continuation -> 'b) option ;
}
So: retc is the value handler, exnc handles exceptions, and effc handles the effects performed by the computation enclosed by the handler. periodt. π«Ά
val continue_with : ('c, 'a) continuation -> 'c -> ('a, 'b) handler -> 'bβcontinue_with k v hresumes the continuationkwith valuevwith the handlerh. π
Raises Continuation_already_resumed if the continuation has already been resumed. (so donβt double-resume, bestie, itβs not that kind of party π)
val discontinue_with : ('c, 'a) continuation -> exn -> ('a, 'b) handler -> 'bβdiscontinue_with k e hresumes the continuationkby raising the exceptionewith the handlerh. dramatic? yes. valid? also yes. π
Raises Continuation_already_resumed if the continuation has already been resumed.
val discontinue_with_backtrace : ('a, 'b) continuation -> exn -> Printexc.raw_backtrace -> ('b, 'c) handler -> 'cβ the doc describes it asdiscontinue_with k e bt h: it resumes the continuationkby raising the exceptionewith the handlerh, using the raw backtracebtas the origin of the exception. backtrace lore fr fr. π₯
Raises Continuation_already_resumed if the continuation has already been resumed.
val get_callstack : ('a, 'b) continuation -> int -> Printexc.raw_backtraceβget_callstack c nreturns a description of the top of the call stack on the continuationc, with at mostnentries. peek at the stack, but make it delimited. β
mwah π β OCamldoc, 2026-06-22. byeee π
π¦ where this page comes from
- arch rolling: ocaml 5.5.0-1 Β· LGPL2.1 AND custom: QPL-1.0
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms