package tezos-lwt-result-stdlib

  1. Overview
  2. Docs
Legend:
Library
Module
Module type
Parameter
Class
Class type
include Bare_sigs.Monad.S
val (>>=) : 'a Lwt.t -> ('a -> 'b Lwt.t) -> 'b Lwt.t
val (>|=) : 'a Lwt.t -> ('a -> 'b) -> 'b Lwt.t

result monad

val ok : 'a -> ('a, 'trace) Stdlib.result
val error : 'error -> ('a, 'error) Stdlib.result
val (>>?) : ('a, 'trace) Stdlib.result -> ('a -> ('b, 'trace) Stdlib.result) -> ('b, 'trace) Stdlib.result
val (>|?) : ('a, 'trace) Stdlib.result -> ('a -> 'b) -> ('b, 'trace) Stdlib.result

lwt-result combined monad

val ok_s : 'a -> ('a, 'trace) Stdlib.result Lwt.t
val return : 'a -> ('a, 'trace) Stdlib.result Lwt.t
val error_s : 'error -> ('a, 'error) Stdlib.result Lwt.t
val fail : 'error -> ('a, 'error) Stdlib.result Lwt.t
val (>>=?) : ('a, 'trace) Stdlib.result Lwt.t -> ('a -> ('b, 'trace) Stdlib.result Lwt.t) -> ('b, 'trace) Stdlib.result Lwt.t
val (>|=?) : ('a, 'trace) Stdlib.result Lwt.t -> ('a -> 'b) -> ('b, 'trace) Stdlib.result Lwt.t

Mixing operators

All operators follow this naming convention:

  • the first character is >
  • the second character is > for bind and | for map
  • the next character is = for Lwt or ? for Error
  • the next character (if present) is = for Lwt or ? for Error, it is only used for operator that are within both monads.
val (>>?=) : ('a, 'trace) Stdlib.result -> ('a -> ('b, 'trace) Stdlib.result Lwt.t) -> ('b, 'trace) Stdlib.result Lwt.t
val (>|?=) : ('a, 'trace) Stdlib.result -> ('a -> 'b Lwt.t) -> ('b, 'trace) Stdlib.result Lwt.t

preallocated in-monad values

val unit_s : unit Lwt.t
val unit_e : (unit, 'trace) Stdlib.result
val unit_es : (unit, 'trace) Stdlib.result Lwt.t
val none_s : 'a option Lwt.t
val none_e : ('a option, 'trace) Stdlib.result
val none_es : ('a option, 'trace) Stdlib.result Lwt.t
val some_s : 'a -> 'a option Lwt.t
val some_e : 'a -> ('a option, 'trace) Stdlib.result
val some_es : 'a -> ('a option, 'trace) Stdlib.result Lwt.t
val nil_s : 'a list Lwt.t
val nil_e : ('a list, 'trace) Stdlib.result
val nil_es : ('a list, 'trace) Stdlib.result Lwt.t
val true_s : bool Lwt.t
val true_e : (bool, 'trace) Stdlib.result
val true_es : (bool, 'trace) Stdlib.result Lwt.t
val false_s : bool Lwt.t
val false_e : (bool, 'trace) Stdlib.result
val false_es : (bool, 'trace) Stdlib.result Lwt.t

additional preallocated in-monad values

this is for backwards compatibility and for similarity with Lwt

val ok_unit : (unit, 'error) Stdlib.result
val return_unit : (unit, 'error) Stdlib.result Lwt.t

joins

val join_p : unit Lwt.t list -> unit Lwt.t
val all_p : 'a Lwt.t list -> 'a list Lwt.t
val both_p : 'a Lwt.t -> 'b Lwt.t -> ('a * 'b) Lwt.t
type 'error trace

'error trace is intended to be substituted by a type provided by a Trace module (with type 'error trace := 'error Trace.trace)

val error_trace : 'error -> ('a, 'error trace) Stdlib.result

error_trace e is Error (Trace.make e) where Trace is the Traced_sigs.Trace module that provides the trace type and functions.

val fail_trace : 'error -> ('a, 'error trace) Stdlib.result Lwt.t

fail_trace e is Lwt.return (Error (Trace.make e)) where Trace is the Traced_sigs.Trace module that provides the trace type and functions.

val join_e : (unit, 'error trace) Stdlib.result list -> (unit, 'error trace) Stdlib.result

join, all, and both all return traces rather than lists of errors. This applies to both result-only and Lwt-result monads.

val all_e : ('a, 'error trace) Stdlib.result list -> ('a list, 'error trace) Stdlib.result
val both_e : ('a, 'error trace) Stdlib.result -> ('b, 'error trace) Stdlib.result -> ('a * 'b, 'error trace) Stdlib.result
val join_ep : (unit, 'error trace) Stdlib.result Lwt.t list -> (unit, 'error trace) Stdlib.result Lwt.t
val all_ep : ('a, 'error trace) Stdlib.result Lwt.t list -> ('a list, 'error trace) Stdlib.result Lwt.t
val both_ep : ('a, 'error trace) Stdlib.result Lwt.t -> ('b, 'error trace) Stdlib.result Lwt.t -> ('a * 'b, 'error trace) Stdlib.result Lwt.t
OCaml

Innovation. Community. Security.