module Option: Generic_util_option
Operations on option types.
val option : ('a -> 'b) -> 'a option -> 'b option
option f
is the functorial action of the functor
'a option
:
Some x -> Some (f x)
None -> None
val map : ('a -> 'b) -> 'a option -> 'b option
val functorial : App.option' Functor.functorial
val unopt : 'a -> ('b -> 'a) -> 'b option -> 'a
unopt s n
eliminates an option value by replacing the constructor Some
by s
and None
by n
.
val get_some : 'a option -> 'a
Partial function
get_some (Some x) = x
Raises Failed
on None
val opt_try : 'a Lazy.t -> 'a option
opt_try x
forces the lazy value x
. If any exception is raised,
None
is returned, otherwise Some x
is returned.
val some_if : ('a -> bool) -> 'a -> 'a option
some_if f x = Some x
if f x
is true, None
otherwise
val unopt_try : 'a -> ('b -> 'a) -> 'b Lazy.t -> 'a
unopt_try s n x = unopt s n (opt_try x)
val leftist_plus : 'a option -> 'a option -> 'a option
Monadic plus, the left argument has priority on the right
in case both options have a value.
val to_list : 'a option -> 'a list