tezos-error-monad

Tezos: error monad
Library tezos-error-monad

The Lwt traced Result monad: for concurrent successes and traced failures

The Lwt_traced_result_syntax module is similar to the Lwt_result_syntax module with the following difference:

  • fail wraps the error in a trace,
  • and* and and+ are provided.

See Lwt_result_syntax.

val return : 'a -> ( 'a, 'error ) result Lwt.t
val return_unit : ( unit, 'error ) result Lwt.t
val return_none : ( 'a option, 'error ) result Lwt.t
val return_some : 'a -> ( 'a option, 'error ) result Lwt.t
val return_nil : ( 'a list, 'error ) result Lwt.t
val return_true : ( bool, 'error ) result Lwt.t
val return_false : ( bool, 'error ) result Lwt.t
val fail : 'error -> ( 'a, 'error Trace.trace ) result Lwt.t

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

val let* : ( 'a, 'e ) result Lwt.t -> ( 'a -> ( 'b, 'e ) result Lwt.t ) -> ( 'b, 'e ) result Lwt.t
val and* : ( 'a, 'e Trace.trace ) result Lwt.t -> ( 'b, 'e Trace.trace ) result Lwt.t -> ( 'a * 'b, 'e Trace.trace ) result Lwt.t
val let+ : ( 'a, 'e ) result Lwt.t -> ( 'a -> 'b ) -> ( 'b, 'e ) result Lwt.t
val and+ : ( 'a, 'e Trace.trace ) result Lwt.t -> ( 'b, 'e Trace.trace ) result Lwt.t -> ( 'a * 'b, 'e Trace.trace ) result Lwt.t
val let*! : 'a Lwt.t -> ( 'a -> 'b Lwt.t ) -> 'b Lwt.t
val let*? : ( 'a, 'e ) result -> ( 'a -> ( 'b, 'e ) result Lwt.t ) -> ( 'b, 'e ) result Lwt.t
val join : ( unit, 'error Trace.trace ) result Lwt.t list -> ( unit, 'error Trace.trace ) result Lwt.t
val all : ( 'a, 'error Trace.trace ) result Lwt.t list -> ( 'a list, 'error Trace.trace ) result Lwt.t
val both : ( 'a, 'error Trace.trace ) result Lwt.t -> ( 'b, 'error Trace.trace ) result Lwt.t -> ( 'a * 'b, 'error Trace.trace ) result Lwt.t