Options
type 'a t = 'a option =| None| Some of 'aThe type for option values. Either
Noneor a valueSome v.
val value : 'a option -> default:'a -> 'avalue o ~defaultisvifoisSome vanddefaultotherwise.
val bind : 'a option -> ('a -> 'b option) -> 'b optionbind o fisf vifoisSome vandNoneifoisNone.
val join : 'a option option -> 'a optionjoin ooisSome vifooisSome (Some v)andNoneotherwise.
val map : ('a -> 'b) -> 'a option -> 'b optionmap f oisNoneifoisNoneandSome (f v)isoisSome v.
val fold : none:'a -> some:('b -> 'a) -> 'b option -> 'afold ~none ~some oisnoneifoisNoneandsome vifoisSome v.
Predicates and comparisons
val equal : ('a -> 'a -> bool) -> 'a option -> 'a option -> boolequal eq o0 o1istrueiffo0ando1are bothNoneor if they areSome v0andSome v1andeq v0 v1istrue.
val compare : ('a -> 'a -> int) -> 'a option -> 'a option -> intcompare cmp o0 o1is a total order on options usingcmpto compare values wrapped bySome _.Noneis smaller thanSome _values.
Converting
val to_result : none:'e -> 'a option -> ('a, 'e) Stdlib.resultto_result ~none oisOk vifoisSome vandError noneotherwise.
val to_seq : 'a option -> 'a Stdlib.Seq.tto_seq oisoas a sequence.Noneis the empty sequence andSome vis the singleton sequence containingv.