HashConsGroundFn functor provides a mechanism for defining
a hash-consed representations for "leaf" (or "ground") types.
These are types that might be atomic (e.g.,
HashConsAtom structure) or
datatypes, but they are treated as atomic values by the HashCons Library
and are the leaves of the hash-consed data structures.
functor HashConsGroundFn (T : HASH_KEY)
T : HASH_KEY:: The argument structure
Tdefines the type, equality function, and hashing function a the "leaf" type.
type hash_key = T.hash_key type obj = hash_key HashCons.obj val mk : hash_key -> obj
type hash_key = T.hash_key
type obj = hash_key HashCons.obj
val mk : hash_key -> obj
Suppose that we wish to have pairs of integers as a ground type for a hash-consed data structure. We might implement this using the following functor application:
structure HCPairs = HashConsGroundFn ( struct type hash_key = int * int fun sameKey (a : hash_key, b) = (a = b) fun hashVal (a, b) = Word.xorb(Word.fromInt a, Word.fromInt b) end)