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
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 result
s 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 …)
.
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.