package tezos-lwt-result-stdlib

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

lwt monad

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) result
val error : 'error -> ('a, 'error) result
val (>>?) : ('a, 'trace) result -> ('a -> ('b, 'trace) result) -> ('b, 'trace) result
val (>|?) : ('a, 'trace) result -> ('a -> 'b) -> ('b, 'trace) result

lwt-result combined monad

val ok_s : 'a -> ('a, 'trace) result Lwt.t
val return : 'a -> ('a, 'trace) result Lwt.t
val error_s : 'error -> ('a, 'error) result Lwt.t
val fail : 'error -> ('a, 'error) result Lwt.t
val (>>=?) : ('a, 'trace) result Lwt.t -> ('a -> ('b, 'trace) result Lwt.t) -> ('b, 'trace) result Lwt.t
val (>|=?) : ('a, 'trace) result Lwt.t -> ('a -> 'b) -> ('b, 'trace) 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) result -> ('a -> ('b, 'trace) result Lwt.t) -> ('b, 'trace) result Lwt.t
val (>|?=) : ('a, 'trace) result -> ('a -> 'b Lwt.t) -> ('b, 'trace) result Lwt.t

preallocated in-monad values

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

additional preallocated in-monad values

this is for backwards compatibility and for similarity with Lwt

val ok_unit : (unit, 'error) result
val return_unit : (unit, 'error) 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
val join_e : (unit, 'trace) result list -> (unit, 'trace list) result
val all_e : ('a, 'trace) result list -> ('a list, 'trace list) result
val both_e : ('a, 'trace) result -> ('b, 'trace) result -> ('a * 'b, 'trace list) result
val join_ep : (unit, 'trace) result Lwt.t list -> (unit, 'trace list) result Lwt.t
val all_ep : ('a, 'trace) result Lwt.t list -> ('a list, 'trace list) result Lwt.t
val both_ep : ('a, 'trace) result Lwt.t -> ('b, 'trace) result Lwt.t -> ('a * 'b, 'trace list) result Lwt.t
OCaml

Innovation. Community. Security.