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 compare_lwt : ('a -> 'a -> int Lwt.t) -> 'a t -> 'a t -> int Lwt.tSame as compare when the comparison function returns an Lwt value.
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 fail : 'a -> 'a -> 'aval second : 'a -> 'a -> 'aval concat : ('a -> 'a -> 'a) -> 'a option -> 'a option -> 'a optionConcatenation of the monoid given the concatenation of the embedded one.
val concat_l : ('a -> 'a -> 'a) -> 'a option list -> 'a optionSame as concat but for a list of options.
val return : 'a -> 'a optionval first : 'a option list -> 'a optionReturn the first element of the list that is not None.
val to_string : string option -> stringMaps None to "" and Some s to s.
val 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.