package tezos-protocol-environment

  1. Overview
  2. Docs
Legend:
Library
Module
Module type
Parameter
Class
Class type

Signature from Lwtreslib's option module

type 'a t = 'a option =
  1. | None
  2. | Some of 'a
val none : 'a option
val none_e : ('a option, 'trace) Pervasives.result
val none_s : 'a option Lwt.t
val none_es : ('a option, 'trace) Pervasives.result Lwt.t
val some : 'a -> 'a option
val some_unit : unit option
val some_nil : 'a list option
val some_e : 'a -> ('a option, 'trace) Pervasives.result
val some_s : 'a -> 'a option Lwt.t
val some_es : 'a -> ('a option, 'trace) Pervasives.result Lwt.t
val value : 'a option -> default:'a -> 'a
val value_e : 'a option -> error:'trace -> ('a, 'trace) Pervasives.result
val value_f : 'a option -> default:(unit -> 'a) -> 'a
val value_fe : 'a option -> error:(unit -> 'trace) -> ('a, 'trace) Pervasives.result
val bind : 'a option -> ('a -> 'b option) -> 'b option
val join : 'a option option -> 'a option
val either : 'a option -> 'a option -> 'a option
val map : ('a -> 'b) -> 'a option -> 'b option
val map_s : ('a -> 'b Lwt.t) -> 'a option -> 'b option Lwt.t
val map_e : ('a -> ('b, 'trace) Pervasives.result) -> 'a option -> ('b option, 'trace) Pervasives.result
val map_es : ('a -> ('b, 'trace) Pervasives.result Lwt.t) -> 'a option -> ('b option, 'trace) Pervasives.result Lwt.t
val fold : none:'a -> some:('b -> 'a) -> 'b option -> 'a
val fold_s : none:'a -> some:('b -> 'a Lwt.t) -> 'b option -> 'a Lwt.t
val fold_f : none:(unit -> 'a) -> some:('b -> 'a) -> 'b option -> 'a
val iter : ('a -> unit) -> 'a option -> unit
val iter_s : ('a -> unit Lwt.t) -> 'a option -> unit Lwt.t
val iter_e : ('a -> (unit, 'trace) Pervasives.result) -> 'a option -> (unit, 'trace) Pervasives.result
val iter_es : ('a -> (unit, 'trace) Pervasives.result Lwt.t) -> 'a option -> (unit, 'trace) Pervasives.result Lwt.t
val is_none : 'a option -> bool
val is_some : 'a option -> bool
val equal : ('a -> 'a -> bool) -> 'a option -> 'a option -> bool
val compare : ('a -> 'a -> int) -> 'a option -> 'a option -> int
val to_result : none:'trace -> 'a option -> ('a, 'trace) Pervasives.result
val of_result : ('a, 'e) Pervasives.result -> 'a option
val to_list : 'a option -> 'a list
val to_seq : 'a option -> 'a Seq.t
val catch : ?catch_only:(exn -> bool) -> (unit -> 'a) -> 'a option

catch f is Some (f ()) if f does not raise an exception, it is None otherwise.

You should only use catch when you truly do not care about what exception may be raised during the evaluation of f (). If you need to inspect the raised exception, or if you need to pass it along, consider Result.catch instead.

If catch_only is set, then only exceptions e such that catch_only e is true are caught.

Whether catch_only is set or not, you cannot catch non-deterministic runtime exceptions of OCaml such as Stack_overflow and Out_of_memory nor system exceptions such as Unix.Unix_error.

val catch_s : ?catch_only:(exn -> bool) -> (unit -> 'a Lwt.t) -> 'a option Lwt.t

catch_s f is a promise that resolves to Some x if and when f () resolves to x. Alternatively, it resolves to None if and when f () is rejected.

You should only use catch_s when you truly do not care about what exception may be raised during the evaluation of f (). If you need to inspect the raised exception, or if you need to pass it along, consider Result.catch_s instead.

If catch_only is set, then only exceptions e such that catch_only e is true are caught.

Whether catch_only is set or not, you cannot catch non-deterministic runtime exceptions of OCaml such as Stack_overflow and Out_of_memory nor system exceptions such as Unix.Unix_error.

OCaml

Innovation. Community. Security.