package octez-libs
Install
dune-project
Dependency
Authors
Maintainers
Sources
sha256=aa2f5bc99cc4ca2217c52a1af2a2cdfd3b383208cb859ca2e79ca0903396ca1d
sha512=d68bb3eb615e3dcccc845fddfc9901c95b3c6dc8e105e39522ce97637b1308a7fa7aa1d271351d5933febd7476b2819e1694f31198f1f0919681f1f9cc97cb3a
doc/octez-libs.lwt-result-stdlib/Tezos_lwt_result_stdlib/Lwtreslib/Traced/Monad/Result_syntax/index.html
Module Monad.Result_syntax
Syntax module for Result. This is intended to be opened locally in functions which use result for control-flow. Within the scope of this module, the code can include binding operators, leading to a let-style syntax.
See also Result
val return : 'a -> ('a, 'e) resultreturn x is Ok x.
val return_unit : (unit, 'e) resultreturn_unit is Ok ().
val return_none : ('a option, 'e) resultreturn_none is Ok None.
val return_some : 'a -> ('a option, 'e) resultreturn_some x is Ok (Some x).
val return_nil : ('a list, 'e) resultreturn_nil is Ok [].
val return_true : (bool, 'e) resultreturn_true is Ok true.
val return_false : (bool, 'e) resultreturn_false is Ok false.
Note that we do not provide return_ok nor return_error. Both of these functions are possible but somewhat confusing and rarely useful in practice. If you need to carry results within a Result-monad computation (yielding to values of the type (('a, 'e) result, 'e) result), you need to do so by hand: return (Ok …) and return (Error …).
val fail : 'e -> ('a, 'e) resultfail e is Error e. It is also an alias for error.
let* is a binding operator alias for Result.bind and >>?.
let+ is a binding operator alias for Result.map and >|?.
Note that we do not provide and* nor and+. Both of these are possible but their type is unsatisfying because the errors do not compose well. You can use both (below) if need be.
join is the joining of success/failure unit values.
all is the joining of success/failure non-unit values.