Module Prime_option
Functions on the 'a option
type.
val get_or : 'a -> 'a option -> 'a
get_or d
is a variant ofget
which mapsNone
tod
instead of raising an exception.
val get_else : (unit -> 'a) -> 'a option -> 'a
get_else h
is a variant ofget
which callsh ()
to handle theNone
case instead of raising an exception.
val search : ('a -> 'b option) -> 'a option -> 'b option
search f None
isNone
andsearch f (Some a)
isf a
.
val flatten : 'a option option -> 'a option
flatten
mapsSome (Some x)
toSome x
and other values toNone
.
Monad
Iteration
val iter : ('a -> unit) -> 'a option -> unit
iter f (Some a)
callsf a
, anditer f None
does nothing.
val fmap : ('a -> 'b option) -> 'a option -> 'b option
fmap f None
isNone
andfmap f (Some a)
isf a
. Functions asfilter ∘ map
and as monadic bind.
val fold : ('a -> 'b -> 'b) -> 'a option -> 'b -> 'b
fold f None
is the identity function andfold f (Some a)
isf a
.
Binary Operators
val inter : ('a -> 'b -> 'c) -> 'a option -> 'b option -> 'c option
val union : ('a -> 'a -> 'a) -> 'a option -> 'a option -> 'a option
val compl : ('a -> 'b -> 'b) -> 'a option -> 'b option -> 'b option
val finter : ('a -> 'b -> 'c option) -> 'a option -> 'b option -> 'c option
val funion : ('a -> 'a -> 'a option) -> 'a option -> 'a option -> 'a option
val fcompl : ('a -> 'b -> 'b option) -> 'a option -> 'b option -> 'b option