Stdlib320.Option
Gets the value of an option if it is not None
. value o ~default:y
is
x
if o = Some x
y
if o = None
A slightly more convenient variant of the previous function, where default y o
is equivalent to value o ~default:y
.
Monadic bind for options. It "does something" to the value of the option if it is not None
, and passes along the None
otherwise. bind o f
is
f x
if o = Some x
None
if o = None
Monadic join for options. If collapses an option whose value is an option into a single option. join oo
is
Some x
if oo = Some (Some x)
None
if oo = Some None
or oo = None
Mapping function for options. It applies a function to the value of the option if the option is not None
. map f o
is
Some (f x)
if o = Some x
None
if o = None
Folding function for options. fold ~none:x some:f o
is equivalent to default x (map f o)
.
Converts an option to a result. to_result ~none:e o
is
Ok x
if o = Some x
Error e
if o = None