mirror of
https://github.com/c-cube/ocaml-containers.git
synced 2025-12-06 03:05:28 -05:00
add function
This commit is contained in:
parent
9cfedad7ba
commit
4c9ab1c659
2 changed files with 9 additions and 0 deletions
|
|
@ -167,6 +167,11 @@ let is_error = function
|
|||
| Ok _ -> false
|
||||
| Error _ -> true
|
||||
|
||||
let split_ok_error results =
|
||||
results
|
||||
|> CCList.partition_filter_map (fun x ->
|
||||
match x with Ok o -> `Left o | Error e -> `Right e)
|
||||
|
||||
(** {2 Wrappers} *)
|
||||
|
||||
let guard f = try Ok (f ()) with e -> Error e
|
||||
|
|
|
|||
|
|
@ -145,6 +145,10 @@ val is_error : ('a, 'err) t -> bool
|
|||
(** Return true if [Error].
|
||||
@since 1.0 *)
|
||||
|
||||
val split_ok_error : ('ok, 'error) result list -> 'ok list * 'error list
|
||||
(** Split a list of results into [Ok]s and [Error]s.
|
||||
@since 3.14.1 *)
|
||||
|
||||
(** {2 Wrappers} *)
|
||||
|
||||
val guard : (unit -> 'a) -> ('a, exn) t
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue