Data.Result
Operations over Result.
The type is wired in; the prelude opens this module, so these are in unqualified scope everywhere.
Functions and Values
is_ok
is_ok : forall a b. (Result(a, b)) -> Bool
True when the result is Ok.
is_err
is_err : forall a b. (Result(a, b)) -> Bool
True when the result is Err.
map_result
map_result : forall e0 a b c. ((c) -> b ! {e0}, Result(c, a)) -> Result(b, a) ! {e0}
Apply f to the Ok value, leaving an Err untouched.
and_then_result
and_then_result : forall e0 a b c. ((a) -> Result(b, c) ! {e0}, Result(a, c)) -> Result(b, c) ! {e0}
Chain a result-returning function, short-circuiting on Err (monadic bind for Result).
result_or
result_or : forall a b. (a, Result(a, b)) -> a
The Ok value, or the default d when the result is Err.
ok_of_option
ok_of_option : forall a b. (a, Option(b)) -> Result(b, a)
Convert an Option to a Result, using err in place of None.
option_of_result
option_of_result : forall a b. (Result(a, b)) -> Option(a)
Convert a Result to an Option, discarding the error.