package pacomb

  1. Overview
  2. Docs

Dependant association lists.

type ('a, 'b) eq =
  1. | Eq : ('a, 'a) eq
  2. | NEq : ('a, 'b) eq

Standard equality type using a GADT.

type _ token = ..

Type of tokens used to make keys unique, and carrying a type. This type is not intended to be extended by the used, hence it is private.

type 'a key = {
  1. tok : 'a token;
  2. uid : int;
  3. eq : 'b. 'b token -> ('a, 'b) eq;
}

Type of a key for a value of type 'a. It contains a unique token and the corresponding (very efficient) equality test.

type any_key =
  1. | K : 'a key -> any_key

To store keys in lists

val new_key : unit -> 'a key

new_key () generates a new unique key for a value of type 'a.

type t

Type of an association list.

val empty : t

empty is the empty association list.

val compare : 'a key -> 'b key -> int

compare keys by uid

val add : 'a key -> 'a -> t -> t

add k v l inserts a new binding of k to v at the head of l.

val length : t -> int

length l returns the size of the association list l.

val add_key : 'a -> t -> 'a key * t

add_key v l is equivalent to let k = new_key () in (k, add k v l).

val find : 'a key -> t -> 'a

find k l returns the latest inserted value with key k in list l. The exception Not_found is raised if there is none.

val mem : 'a key -> t -> bool

mem k l tells whether an element is mapped to k in the list l.

val remove : 'a key -> t -> t

remove k l removes the latest inserted binding of the key k in l. If there is no such binding, then Not_found is raised.

val append : t -> t -> t
OCaml

Innovation. Community. Security.