Module CCListLabels.Assoc

type ('a, 'b) t = ('a * 'b) list
val get : eq:('a -> 'a -> bool) -> 'a -> ('a'b) t -> 'b option

get ~eq k alist returns Some v if the given key k is present into alist, or None if not present.

val get_exn : eq:('a -> 'a -> bool) -> 'a -> ('a'b) t -> 'b

get_exn ~eq k alist returns v if the element k is present into alist. Like get, but unsafe.

raises Not_found

if the element is not present.

val set : eq:('a -> 'a -> bool) -> 'a -> 'b -> ('a'b) t -> ('a'b) t

set ~eq k v alist adds the binding k, v into the list alist (erase it if already present).

val mem : ?⁠eq:('a -> 'a -> bool) -> 'a -> ('a_) t -> bool

mem ?eq k alist returns true iff k is a key in alist.

since
0.16
val update : eq:('a -> 'a -> bool) -> f:('b option -> 'b option) -> 'a -> ('a'b) t -> ('a'b) t

update ~eq ~f k alist updates alist on the key k, by calling f (get alist k) and removing k if it returns None, mapping k to v' if it returns Some v'.

since
0.16
val remove : eq:('a -> 'a -> bool) -> 'a -> ('a'b) t -> ('a'b) t

remove ~eq k alist returns the alist without the first pair with key k, if any.

since
0.17