package fix

  1. Overview
  2. Docs

This module offers a facility for assigning a unique number to each value in a certain finite set and translating (both ways) between values and their numbers.

module Make (M : sig ... end) : sig ... end

The functor Make requires an implementation of maps for the type M.key and offers a two-phase numbering facility. The function encode is backed by a map, therefore runs in logarithmic time or constant time, depending on the type of map that is used. The function decode is backed by an array of size n, therefore runs in constant time.

module ForOrderedType (T : Map.OrderedType) : sig ... end

ForOrderedType is a special case of Make where it suffices for keys to be ordered.

module ForHashedType (T : Hashtbl.HashedType) : sig ... end

ForHashedType is a special case of Make where it suffices for keys to be hashed.

module ForType (T : sig ... end) : sig ... end

ForType is a special case of Make where keys can have arbitrary type. OCaml's built-in generic equality and hash functions are used.

OCaml

Innovation. Community. Security.