mirror of
https://github.com/c-cube/ocaml-containers.git
synced 2025-12-06 11:15:31 -05:00
Add CCOpt.flatten
This commit is contained in:
parent
d8caef8c02
commit
bbda79bbcc
2 changed files with 14 additions and 0 deletions
|
|
@ -208,3 +208,13 @@ let to_seq o k = match o with
|
|||
let pp ppx out = function
|
||||
| None -> Format.pp_print_string out "None"
|
||||
| Some x -> Format.fprintf out "@[Some %a@]" ppx x
|
||||
|
||||
let flatten = function
|
||||
| Some x -> x
|
||||
| None -> None
|
||||
|
||||
(*$T
|
||||
flatten None = None
|
||||
flatten (Some None) = None
|
||||
flatten (Some (Some 1)) = Some 1
|
||||
*)
|
||||
|
|
|
|||
|
|
@ -122,6 +122,10 @@ val (<+>) : 'a t -> 'a t -> 'a t
|
|||
val choice : 'a t list -> 'a t
|
||||
(** [choice] returns the first non-[None] element of the list, or [None]. *)
|
||||
|
||||
val flatten : 'a t t -> 'a t
|
||||
(** [flatten] transforms [Some x] into [x].
|
||||
@since NEXT_RELEASE *)
|
||||
|
||||
(** {2 Infix Operators}
|
||||
@since 0.16 *)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue