Data.Maybe
Operations over Option.
The type is wired in; the prelude opens this module, so these are in unqualified scope everywhere.
Functions and Values
is_some
is_some : forall a. (Option(a)) -> Bool
True when the option holds a value.
is_none
is_none : forall a. (Option(a)) -> Bool
True when the option is empty.
unwrap_or
unwrap_or : forall a. (a, Option(a)) -> a
The contained value, or the default d when the option is empty.
unwrap_or(0, Some(5))
map_option
map_option : forall e0 a b. ((b) -> a ! {e0}, Option(b)) -> Option(a) ! {e0}
Apply f to the contained value, leaving None untouched.
The default d here is not an option, so this example is rejected:
unwrap_or(0, 5)
and_then
and_then : forall e0 a b. ((a) -> Option(b) ! {e0}, Option(a)) -> Option(b) ! {e0}
Chain an option-returning function, short-circuiting on None (monadic bind for Option).
map_or
map_or : forall e0 a b. (a, (b) -> a ! {e0}, Option(b)) -> a ! {e0}
option_or
option_or : forall a. (Option(a), Option(a)) -> Option(a)
option_to_list
option_to_list : forall a. (Option(a)) -> List(a)
both
both : forall a b. (Option(a), Option(b)) -> Option((a, b))
option_fold_r
option_fold_r : forall e0 a b. ((a, b) -> b ! {e0}, b, Option(a)) -> b ! {e0}
option_fold_l
option_fold_l : forall e0 a b. ((a, b) -> a ! {e0}, a, Option(b)) -> a ! {e0}
option_bind
option_bind : forall e0 a b. (Option(a), (a) -> Option(b) ! {e0}) -> Option(b) ! {e0}
option_ap
option_ap : forall e0 a b. (Option((b) -> a ! {e0}), Option(b)) -> Option(a) ! {e0}