mirror of
https://github.com/c-cube/ocaml-containers.git
synced 2025-12-06 11:15:31 -05:00
add Option.flat_map_l
This commit is contained in:
parent
d985019fe1
commit
9261e654e7
2 changed files with 9 additions and 0 deletions
|
|
@ -46,6 +46,11 @@ let[@inline] flat_map f o =
|
|||
| None -> None
|
||||
| Some x -> f x
|
||||
|
||||
let[@inline] flat_map_l f o =
|
||||
match o with
|
||||
| None -> []
|
||||
| Some x -> f x
|
||||
|
||||
let[@inline] bind o f = flat_map f o
|
||||
let ( >>= ) = bind
|
||||
let pure x = Some x
|
||||
|
|
|
|||
|
|
@ -49,6 +49,10 @@ val flat_map : ('a -> 'b t) -> 'a t -> 'b t
|
|||
(** [flat_map f o] is equivalent to {!map} followed by {!flatten}.
|
||||
Flip version of {!(>>=)}. *)
|
||||
|
||||
val flat_map_l : ('a -> 'b list) -> 'a t -> 'b list
|
||||
(** [flat_map_l f o] is [[]] if [o] is [None], or [f x] if [o] is [Some x].
|
||||
@since NEXT_RELEASE *)
|
||||
|
||||
val bind : 'a t -> ('a -> 'b t) -> 'b t
|
||||
(** [bind o f] is [f v] if [o] is [Some v], [None] otherwise.
|
||||
Monadic bind.
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue