diff --git a/src/core/CCList.ml b/src/core/CCList.ml index 87c7fefc..fa82eaeb 100644 --- a/src/core/CCList.ml +++ b/src/core/CCList.ml @@ -1048,6 +1048,13 @@ let all_ok l = | None -> assert false | Some e -> Error e) +let split_result results = + results + |> partition_filter_map (fun x -> + match x with + | Ok o -> `Left o + | Error e -> `Right e) + let group_by (type k) ?(hash = Hashtbl.hash) ?(eq = Stdlib.( = )) l = let module Tbl = Hashtbl.Make (struct type t = k diff --git a/src/core/CCList.mli b/src/core/CCList.mli index b9507f77..d9c941d0 100644 --- a/src/core/CCList.mli +++ b/src/core/CCList.mli @@ -495,6 +495,10 @@ val all_ok : ('a, 'err) result t -> ('a t, 'err) result @since 1.3, but only @since 2.2 with labels *) +val split_result : ('ok, 'error) result list -> 'ok list * 'error list +(** Split a list of results into [Ok]s and [Error]s. + @since 3.14.1 *) + val sorted_mem : cmp:('a -> 'a -> int) -> 'a -> 'a list -> bool (** [sorted_mem ~cmp x l] and [mem x l] give the same result for any sorted list [l], but potentially more efficiently. diff --git a/src/core/CCResult.ml b/src/core/CCResult.ml index 14437120..69bbab60 100644 --- a/src/core/CCResult.ml +++ b/src/core/CCResult.ml @@ -167,13 +167,6 @@ 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 diff --git a/src/core/CCResult.mli b/src/core/CCResult.mli index 21e339e4..5347b3fd 100644 --- a/src/core/CCResult.mli +++ b/src/core/CCResult.mli @@ -145,10 +145,6 @@ 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