The type 'data cell describes a cell that carries a unique identifier id as well as a payload data.
This type is marked private, which means that the user has no direct way of allocating cells. Instead, the user must apply the functor Make (below) to obtain a function make which either allocates a fresh cell or returns an existing cell. The user is still allowed to read existing cells.
Cells come with an equality test equal, a comparison function compare, and and a hash function hash. These functions exploit the cell's unique identifier only: the data is ignored.
As a result, wherever a module of signature HashedType with type t = foo cell is expected, the module HashCons can be supplied. This holds regardless of the type foo.
A hash-consing service allocates uniquely-numbered cells for data. The smart constructor make either allocates a fresh cell or returns an existing cell, as appropriate.
ForHashedTypeWeak is a special case of Make where it suffices to pass a hashed type T as an argument. A weak hash table is used to hold the memoization table.