val some_es : 'a->('a option, 'trace)Stdlib.resultLwt.t
val value : 'a option->default:'a->'a
val value_e : 'a option->error:'trace->('a, 'trace)Stdlib.result
val value_f : 'a option->default:(unit ->'a)->'a
val value_fe :
'a option->error:(unit ->'trace)->('a, 'trace)Stdlib.result
val bind : 'a option->('a->'b option)->'b option
val join : 'a option option->'a option
val either : 'a option->'a option->'a option
either picks the first Some _ value of its arguments if any. More formally, either (Some x) _ is Some x, either None (Some y) is Some y, and either None None is None.
val either_f : 'a option->(unit ->'a option)->'a option
val merge : ('a->'a->'a)->'a option->'a option->'a option
val merge_e :
('a->'a->('a, 'e)Stdlib.result)->'a option->'a option->('a option, 'e)Stdlib.result
val merge_s :
('a->'a->'aLwt.t)->'a option->'a option->'a optionLwt.t
val merge_es :
('a->'a->('a, 'e)Stdlib.resultLwt.t)->'a option->'a option->('a option, 'e)Stdlib.resultLwt.t
val map : ('a->'b)->'a option->'b option
val map_s : ('a->'bLwt.t)->'a option->'b optionLwt.t
val map_e :
('a->('b, 'trace)Stdlib.result)->'a option->('b option, 'trace)Stdlib.result
val map_es :
('a->('b, 'trace)Stdlib.resultLwt.t)->'a option->('b option, 'trace)Stdlib.resultLwt.t
val fold : none:'a->some:('b->'a)->'b option->'a
val fold_s : none:'a->some:('b->'aLwt.t)->'b option->'aLwt.t
val fold_f : none:(unit ->'a)->some:('b->'a)->'b option->'a
val filter : ('a-> bool)->'a option->'a option
filter p o is Some x iff o is Some x and p o is true.
In other words, filter is like List.filter if option is the type of lists of either zero or one elements. In fact, the following equality holds for all p and for all o: Option.filter p o = List.hd (List.filter p (Option.to_list o))
The other filter variants below are also equivalent to their List counterpart and a similar equality holds.
val filter_map : ('a->'b option)->'a option->'b option
filter_map is the Option counterpart to List's filter_map. Incidentally, filter_map f o is also bind o f.
val filter_s : ('a->bool Lwt.t)->'a option->'a optionLwt.t
filter_s is filter where the predicate returns a promise.
val filter_map_s : ('a->'b optionLwt.t)->'a option->'b optionLwt.t
filter_map_s is filter_map where the function returns a promise.
val filter_e :
('a->(bool, 'e)Stdlib.result)->'a option->('a option, 'e)Stdlib.result
filter_e is filter where the predicate returns a result.
val filter_map_e :
('a->('b option, 'e)Stdlib.result)->'a option->('b option, 'e)Stdlib.result
filter_map_e is filter_map where the function returns a result.
val filter_es :
('a->(bool, 'e)Stdlib.resultLwt.t)->'a option->('a option, 'e)Stdlib.resultLwt.t
filter_es is filter where the predicate returns a promise of a result.
val filter_map_es :
('a->('b option, 'e)Stdlib.resultLwt.t)->'a option->('b option, 'e)Stdlib.resultLwt.t
filter_map_es is filter_map where the function returns a promise of a result.
val filter_ok : ('a, 'e)Stdlib.result option->'a option
filter_ok o is Some x iff o is Some (Ok x).
val filter_error : ('a, 'e)Stdlib.result option->'e option
filter_error o is Some x iff o is Some (Error x).
val iter : ('a-> unit)->'a option-> unit
val iter_s : ('a->unit Lwt.t)->'a option->unit Lwt.t
val iter_e :
('a->(unit, 'trace)Stdlib.result)->'a option->(unit, 'trace)Stdlib.result
val iter_es :
('a->(unit, 'trace)Stdlib.resultLwt.t)->'a option->(unit, 'trace)Stdlib.resultLwt.t
val is_none : 'a option-> bool
val is_some : 'a option-> bool
val equal : ('a->'a-> bool)->'a option->'a option-> bool
val compare : ('a->'a-> int)->'a option->'a option-> int
val to_result : none:'trace->'a option->('a, 'trace)Stdlib.result
val of_result : ('a, 'e)Stdlib.result->'a option
val to_list : 'a option->'a list
val to_seq : 'a option->'aStdlib.Seq.t
val catch : ?catch_only:(exn -> bool)->(unit ->'a)->'a option
catch f is Some (f ()) if f does not raise an exception, it is None otherwise.
You should only use catch when you truly do not care about what exception may be raised during the evaluation of f (). If you need to inspect the raised exception, or if you need to pass it along, consider Result.catch instead.
If catch_only is set, then only exceptions e such that catch_only e is true are caught.
Whether catch_only is set or not, this function never catches non-deterministic runtime exceptions of OCaml such as Stack_overflow and Out_of_memory.
val catch_o : ?catch_only:(exn -> bool)->(unit ->'a option)->'a option
catch_o f is equivalent to join @@ catch f. In other words, it is f () if f doesn't raise any exception, and it is None otherwise.
catch_only has the same behaviour and limitations as with catch.
val catch_s :
?catch_only:(exn -> bool)->(unit ->'aLwt.t)->'a optionLwt.t
catch_s f is a promise that resolves to Some x if and when f () resolves to x. Alternatively, it resolves to None if and when f () is rejected.
You should only use catch_s when you truly do not care about what exception may be raised during the evaluation of f (). If you need to inspect the raised exception, or if you need to pass it along, consider Result.catch_s instead.
If catch_only is set, then only exceptions e such that catch_only e is true are caught.
Whether catch_only is set or not, this function never catches non-deterministic runtime exceptions of OCaml such as Stack_overflow and Out_of_memory.
val catch_os :
?catch_only:(exn -> bool)->(unit ->'a optionLwt.t)->'a optionLwt.t
catch_os f is like catch_s f where f returns a promise that resolves to an option. catch_os f resolves to None if f () resolves to None or is rejected. It resolves to Some _ if f () does.
catch_only has the same behaviour and limitations as with catch.