Module Await_kernel.Or_canceledSource

Result of a cancellable operation that is either Completed _ or Canceled.

Sourcetype ('a : value_or_null) t =
  1. | Canceled
  2. | Completed of 'a

The type for the result of a cancellable operation.

include sig ... end
Sourceval compare : ('a : value_or_null). ('a -> 'a -> Base.int) -> 'a t -> 'a t -> Base.int
Sourceval compare__local : ('a : value_or_null). ('a @ local -> 'a @ local -> Base.int) -> 'a t @ local -> 'a t @ local -> Base.int
Sourceval equal : ('a : value_or_null). ('a -> 'a -> Base.bool) -> 'a t -> 'a t -> Base.bool
Sourceval equal__local : ('a : value_or_null). ('a @ local -> 'a @ local -> Base.bool) -> 'a t @ local -> 'a t @ local -> Base.bool
Sourceval globalize : ('a : value_or_null). ('a @ local -> 'a) -> 'a t @ local -> 'a t
Sourceval sexp_of_t : ('a : value_or_null). ('a -> Sexplib0.Sexp.t) -> 'a t -> Sexplib0.Sexp.t
Sourceval sexp_of_t__stack : ('a : value_or_null). ('a @ local -> Sexplib0.Sexp.t @ local) -> 'a t @ local -> Sexplib0.Sexp.t @ local
Sourceval t_of_sexp : ('a : value_or_null). (Sexplib0.Sexp.t -> 'a) -> Sexplib0.Sexp.t -> 'a t
Sourceval t_sexp_grammar : ('a : value_or_null). 'a Sexplib0.Sexp_grammar.t -> 'a t Sexplib0.Sexp_grammar.t @@ portable
Sourceval completed_exn : ('a : value_or_null). 'a t -> 'a @@ portable

completed_exn t is a if t is Completed a, otherwise it raises

Sourceval never_completed : Base.Nothing.t t @ local -> Base.unit @@ portable

never_completed t can be used for an Or_canceled.t computation which either loops forever or is canceled.

Monad interface

include Base.Monad.S__local with type 'a t := 'a t
Sourceval return : 'a 'i 'p 'q. 'a -> 'a t

Convert a value to a t.

Sourceval map : 'a 'b 'i 'j 'p 'q. 'a t -> f:('a -> 'b) @ local -> 'b t

Transforms the contents of a t.

Sourceval bind : 'a 'b 'i 'j 'k 'p 'q. 'a t -> f:('a -> 'b t) @ local -> 'b t

Sequences computations. bind t ~f computes f v for value(s) v in t. Well-behaved monads satisfy these "laws" (where ( >>= ) is the infix bind operator):

  • map t ~f is equivalent to bind t ~f:(fun x -> return (f x))
  • return x >>= f is equivalent to f x
  • t >>= return is equivalent to t
  • (t >>= f) >>= g is equivalent to t >>= fun x -> f x >>= g
Sourceval join : 'a 'i 'j 'k 'p 'q. 'a t t -> 'a t

Combines nested t into just one layer. Equivalent to bind t ~f:Fn.id.

Sourceval ignore_m : 'a 'i 'j 'p 'q. 'a t -> unit t

Ignores contained values of t. Equivalent to map t ~f:ignore.

Sourceval all : 'a 'i 'p 'q. 'a t list -> 'a list t

Combines a list of t.

Sourceval all_unit : 'i 'p 'q. unit t list -> unit t

Combines a list of t whose contents are unimportant.

Sourceval (>>=) : 'a 'b 'i 'j 'k 'p 'q. 'a t -> ('a -> 'b t) @ local -> 'b t

Infix bind.

Sourceval (>>|) : 'a 'b 'i 'j 'p 'q. 'a t -> ('a -> 'b) @ local -> 'b t

Infix map.

Sourcemodule Monad_infix : sig ... end
Sourcemodule Let_syntax : sig ... end

Exception based interface for experts

Sourcemodule Exn : sig ... end

Provides a way to implement cancellable and non-cancellable variants of an operation through a single exception raising implementation.