package tezos-lwt-result-stdlib
Install
Dune Dependency
Authors
Maintainers
Sources
sha256=6b33e0549574c89a63538c94ce5555dd141e3c0fb5d934abff07d702fa3244d2
sha512=681a197baabec6e2f806871d43490382243207518f8fcf932741cd314d8717e46db2b6a5adc222f8726083a5dd911083b4931b7e878ab815f8f1a32763d1bf93
doc/bare_structs/Bare_structs/Option/index.html
Module Bare_structs.Option
include Bare_sigs.Option.S
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
.
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
.
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.result Lwt.t) ->
'a option ->
('a option, 'e) Stdlib.result Lwt.t
filter_es
is filter
where the predicate returns a promise of a result
.
val filter_map_es :
('a -> ('b option, 'e) Stdlib.result Lwt.t) ->
'a option ->
('b option, 'e) Stdlib.result Lwt.t
filter_map_es
is filter_map
where the function returns a promise of a result
.
filter_ok o
is Some x
iff o
is Some (Ok x)
.
filter_error o
is Some x
iff o
is Some (Error x)
.