Module Observe_lwt.IO

Observe effects backed by Lwt promises and callback-local bindings.

Dynamic bindings propagate through Lwt callbacks registered inside their scope. They do not propagate through Lwt_preemptive.detach, OS threads, or another I/O implementation. Native Lwt.Canceled remains control flow.

type 'a t = 'a Lwt.t
type state = t
type 'a key
val return : 'a -> 'a t
val bind : 'a t -> ('a -> 'b t) -> 'b t
val observe : (unit -> 'a t) -> 'a Observe.IO.outcome t

Observe effect settlement as the exact result or the same exception and raw backtrace at the runtime failure boundary. Cancellation remains a classified Raised outcome.

val repropagate : exn -> Stdlib.Printexc.raw_backtrace -> 'a t

Re-propagate that exception through the runtime effect.

val create_key : unit -> 'a key

Return a fresh generative dynamic-context key.

val get : state -> 'a key -> 'a option

Read only the binding associated with the supplied key.

val with_binding : state -> 'a key -> 'a -> (unit -> 'b t) -> 'b t

Restore the previous binding after success, exception, or native cancellation.

val protect : state -> finally:(unit -> unit) -> (unit -> 'a t) -> 'a t

Run finally exactly once after the callback settles. When finally returns normally, preserve the callback's result, exception, or native cancellation. The cleanup hook must not raise.

val is_control_exception : state -> exn -> bool

Identify native cancellation and other control-flow exceptions that the core must preserve rather than contain.

module Clock : sig ... end
module Identity : sig ... end
module Sampling : sig ... end
module Console : sig ... end