package octez-libs
Install
    
    dune-project
 Dependency
Authors
Maintainers
Sources
sha256=aa2f5bc99cc4ca2217c52a1af2a2cdfd3b383208cb859ca2e79ca0903396ca1d
    
    
  sha512=d68bb3eb615e3dcccc845fddfc9901c95b3c6dc8e105e39522ce97637b1308a7fa7aa1d271351d5933febd7476b2819e1694f31198f1f0919681f1f9cc97cb3a
    
    
  doc/octez-libs.lwt-result-stdlib/Tezos_lwt_result_stdlib/Lwtreslib/Bare/Option/index.html
Module Bare.OptionSource
val none_e : ('a option, 'trace) resultval none_s : 'a option Lwt.tval some_unit_e : (unit option, 'error) resultval some_unit_s : unit option Lwt.tval some_nil_e : ('a list option, 'error) resultval some_nil_s : 'a list option Lwt.tval some_true_e : (bool option, 'error) resultval some_true_s : bool option Lwt.tval some_false_e : (bool option, 'error) resultval some_false_s : bool option Lwt.tval some_e : 'a -> ('a option, 'trace) resultval some_s : 'a -> 'a option Lwt.tval value_e : 'a option -> error:'trace -> ('a, 'trace) resultval value_fe : 'a option -> error:(unit -> 'trace) -> ('a, 'trace) resulteither 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.
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.
filter_map is the Option counterpart to List's filter_map. Incidentally, filter_map f o is also bind o f.
filter_s is filter where the predicate returns a promise.
filter_map_s is filter_map where the function returns a promise.
filter_e is filter where the predicate returns a result.
filter_map_e is filter_map where the function returns a result.
filter_es is filter where the predicate returns a promise of a result.
val filter_map_es : 
  ('a -> ('b option, 'e) result Lwt.t) ->
  'a option ->
  ('b option, 'e) result Lwt.tfilter_map_es is filter_map where the function returns a promise of a result.
val filter_ok : ('a, 'e) result option -> 'a optionfilter_ok o is Some x iff o is Some (Ok x).
val filter_error : ('a, 'e) result option -> 'e optionfilter_error o is Some x iff o is Some (Error x).
val filter_left : ('a, 'b) Either.t option -> 'a optionfilter_left o is Some x iff o is Some (Either.Left x).
val filter_right : ('a, 'b) Either.t option -> 'b optionfilter_right o is Some x iff o is Some (Either.Right x).
val to_result : none:'trace -> 'a option -> ('a, 'trace) resultval of_result : ('a, 'e) result -> 'a optionval to_seq : 'a option -> 'a Seq.tcatch 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.
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.
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.
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.