tezos-error-monad

Tezos: error monad
Library tezos-error-monad

The traced Result monad: for successes and traced failures

The Traced_result_syntax module is similar to the Result_syntax module with the following differences:

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

See Result_syntax.

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

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

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