diff --git a/src/core/CCList.ml b/src/core/CCList.ml index 9f6e6b82..ec33ae71 100644 --- a/src/core/CCList.ml +++ b/src/core/CCList.ml @@ -1313,6 +1313,11 @@ module Assoc = struct *) end +let assoc = Assoc.get_exn +let assoc_opt = Assoc.get +let mem_assoc = Assoc.mem +let remove_assoc = Assoc.remove + (** {2 References on Lists} *) module Ref = struct diff --git a/src/core/CCList.mli b/src/core/CCList.mli index 47ac6a3c..08e6b1a5 100644 --- a/src/core/CCList.mli +++ b/src/core/CCList.mli @@ -463,14 +463,26 @@ module Assoc : sig @since 0.17 *) end -val assoc_opt : 'a -> ('a * 'b) t -> 'b option -(** Safe version of {!assoc} +val assoc : eq:('a -> 'a -> bool) -> 'a -> ('a * 'b) t -> 'b +(** Same as [Assoc.get_exn] + @since NEXT_RELEASE *) + +val assoc_opt : eq:('a -> 'a -> bool) -> 'a -> ('a * 'b) t -> 'b option +(** Same as [Assoc.get] @since 1.5 *) val assq_opt : 'a -> ('a * 'b) t -> 'b option (** Safe version of {!assq} @since 1.5 *) +val mem_assoc : eq:('a -> 'a -> bool) -> 'a -> ('a * _) t -> bool +(** Same as [Assoc.mem] + @since NEXT_RELEASE *) + +val remove_assoc : eq:('a -> 'a -> bool) -> 'a -> ('a * 'b) t -> ('a * 'b) t +(** Same as [Assoc.remove] + @since NEXT_RELEASE *) + (** {2 References on Lists} @since 0.3.3 *) diff --git a/src/core/CCListLabels.mli b/src/core/CCListLabels.mli index cb86b25c..ffa3d94b 100644 --- a/src/core/CCListLabels.mli +++ b/src/core/CCListLabels.mli @@ -346,6 +346,26 @@ module Assoc : sig @since 0.17 *) end +val assoc : eq:('a -> 'a -> bool) -> 'a -> ('a * 'b) t -> 'b +(** Same as [Assoc.get_exn] + @since NEXT_RELEASE *) + +val assoc_opt : eq:('a -> 'a -> bool) -> 'a -> ('a * 'b) t -> 'b option +(** Same as [Assoc.get] + @since NEXT_RELEASE *) + +val assq_opt : 'a -> ('a * 'b) t -> 'b option +(** Safe version of {!assq} + @since NEXT_RELEASE *) + +val mem_assoc : eq:('a -> 'a -> bool) -> 'a -> ('a * _) t -> bool +(** Same as [Assoc.mem] + @since NEXT_RELEASE *) + +val remove_assoc : eq:('a -> 'a -> bool) -> 'a -> ('a * 'b) t -> ('a * 'b) t +(** Same as [Assoc.remove] + @since NEXT_RELEASE *) + (** {2 References on Lists} @since 0.3.3 *)