module Option:Functions for the Option type.sig
..end
val is_some : 'a option -> bool
is_some (Some x)
not (is_some None)
val is_none : 'a option -> bool
not (is_none (Some x))
is_none None
val value : 'a option -> 'a
Invalid_argument
when applied to None
.
value (Some x) = x
val default : 'a -> 'a option -> 'a
default d (Some x) = x
default d None = d
val classify : ('a -> bool) -> 'a -> 'a option
p x = (classify p x = Some x)
not (p x) = (classify p x = None)
val perform : ('a -> unit) -> 'a option -> unit
apply c (Some x)
does c x
, while apply f None
does
nothing.
val map : ('a -> 'b) -> 'a option -> 'b option
map f (Some x) = Some (f x)
map f None = None
val filter : ('a -> bool) -> 'a option -> 'a option
filter p (Some x)
is Some x
when p x
holds and None
otherwise, while filter p None
is None
.
val flatten : 'a option option -> 'a option
flatten (Some x) = x
Flatten None = None