jon.recoil.org

Module Hmap

Heterogeneous value maps.

v0.8.1 - homepage

Keys

type 'a key

The type for keys whose lookup value is of type 'a.

module Key : sig ... end

Keys.

Maps

type t

The type for heterogeneous value maps.

val empty : Hmap.t

empty is the empty map.

val is_empty : Hmap.t -> bool

is_empty m is true iff m is empty.

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

mem k m is true iff k is bound in m.

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

add k v m is m with k bound to v.

val singleton : 'a Hmap.key -> 'a -> Hmap.t

singleton k v is add k v empty.

val rem : 'a Hmap.key -> Hmap.t -> Hmap.t

rem k m is m with k unbound.

val find : 'a Hmap.key -> Hmap.t -> 'a option

find k m is the value of k's binding in m, if any.

val get : 'a Hmap.key -> Hmap.t -> 'a

get k m is the value of k's binding in m.

type binding =
  1. | B : 'a Hmap.key * 'a -> Hmap.binding

The type for bindings.

val iter : (Hmap.binding -> unit) -> Hmap.t -> unit

iter f m applies f to all bindings of m.

val fold : (Hmap.binding -> 'a -> 'a) -> Hmap.t -> 'a -> 'a

fold f m acc folds over the bindings of m with f, starting with acc

val for_all : (Hmap.binding -> bool) -> Hmap.t -> bool

for_all p m is true iff all bindings of m satisfy p.

val exists : (Hmap.binding -> bool) -> Hmap.t -> bool

exists p m is true iff there exists a bindings of m that satisfies p.

val filter : (Hmap.binding -> bool) -> Hmap.t -> Hmap.t

filter p m are the bindings of m that satisfy p.

val cardinal : Hmap.t -> int

cardinal m is the number of bindings in m.

val any_binding : Hmap.t -> Hmap.binding option

any_binding m is a binding of m (if not empty).

val get_any_binding : Hmap.t -> Hmap.binding

get_any_binding m is a binding of m.

Functorial interface

The functorial interface allows to associate more information to the keys. For example a key name or a key value pretty-printer.

module type KEY_INFO = sig ... end

The type for key information.

module type S = sig ... end

Output signature of the functor Make

module Make (Key_info : Hmap.KEY_INFO) : Hmap.S with type 'a Key.info = 'a Key_info.t

Functor for heterogeneous maps whose keys hold information of type Key_info.t