Options
Standard Library
This module contains everything defined for lists by the OCaml standard library. For these functions, refer to the official documentation.
include module type of Stdlib.Option
type !'a t = 'a option = | None| Some of 'a
val some : 'a -> 'a optionval value : 'a option -> default:'a -> 'aval get : 'a option -> 'aval bind : 'a option -> ('a -> 'b option) -> 'b optionval join : 'a option option -> 'a optionval map : ('a -> 'b) -> 'a option -> 'b optionval fold : none:'a -> some:('b -> 'a) -> 'b option -> 'aval iter : ('a -> unit) -> 'a option -> unitval is_none : 'a option -> boolval is_some : 'a option -> boolval equal : ('a -> 'a -> bool) -> 'a option -> 'a option -> boolval compare : ('a -> 'a -> int) -> 'a option -> 'a option -> intval to_result : none:'e -> 'a option -> ('a, 'e) Stdlib.resultval to_list : 'a option -> 'a listval to_seq : 'a option -> 'a Stdlib.Seq.tAdditional Contents
val choose : tie:('a -> 'a -> 'a) -> 'a t -> 'a t -> 'a tchoose ~tie first second returns Some x when one of first or second is Some x and the other is bottom. If they are both None, None is returned. If they are both Some, tie is called.
val first : 'a -> 'a -> 'aval second : 'a -> 'a -> 'aval return : 'a -> 'a optionval of_string_nonempty : string -> string optionMaps "" to None and other strings to Some.
val fold' : none:(unit -> 'a) -> some:('b -> 'a) -> 'b option -> 'aVariant of fold where ~none is a thunk.
val value' : default:(unit -> 'a) -> 'a option -> 'aVariant of default where ~default is a thunk.
val map_to_list : ('a -> 'b) -> 'a option -> 'b listmap_to_list f x is a convenient shortcut for to_list @@ map f x.
val flip_map : 'a option -> ('a -> 'b) -> 'b optionval flip_map_to_list : 'a option -> ('a -> 'b) -> 'b list