mirror of
https://github.com/c-cube/ocaml-containers.git
synced 2025-12-06 11:15:31 -05:00
move and rename
This commit is contained in:
parent
55d088f0d4
commit
65c604ca2b
4 changed files with 11 additions and 11 deletions
|
|
@ -1048,6 +1048,13 @@ let all_ok l =
|
||||||
| None -> assert false
|
| None -> assert false
|
||||||
| Some e -> Error e)
|
| 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 group_by (type k) ?(hash = Hashtbl.hash) ?(eq = Stdlib.( = )) l =
|
||||||
let module Tbl = Hashtbl.Make (struct
|
let module Tbl = Hashtbl.Make (struct
|
||||||
type t = k
|
type t = k
|
||||||
|
|
|
||||||
|
|
@ -495,6 +495,10 @@ val all_ok : ('a, 'err) result t -> ('a t, 'err) result
|
||||||
@since 1.3, but only
|
@since 1.3, but only
|
||||||
@since 2.2 with labels *)
|
@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
|
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],
|
(** [sorted_mem ~cmp x l] and [mem x l] give the same result for any sorted list [l],
|
||||||
but potentially more efficiently.
|
but potentially more efficiently.
|
||||||
|
|
|
||||||
|
|
@ -167,13 +167,6 @@ let is_error = function
|
||||||
| Ok _ -> false
|
| Ok _ -> false
|
||||||
| Error _ -> true
|
| 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} *)
|
(** {2 Wrappers} *)
|
||||||
|
|
||||||
let guard f = try Ok (f ()) with e -> Error e
|
let guard f = try Ok (f ()) with e -> Error e
|
||||||
|
|
|
||||||
|
|
@ -145,10 +145,6 @@ val is_error : ('a, 'err) t -> bool
|
||||||
(** Return true if [Error].
|
(** Return true if [Error].
|
||||||
@since 1.0 *)
|
@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} *)
|
(** {2 Wrappers} *)
|
||||||
|
|
||||||
val guard : (unit -> 'a) -> ('a, exn) t
|
val guard : (unit -> 'a) -> ('a, exn) t
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue