OCaml hash-consing library
The technique is described in this paper:
Sylvain Conchon and Jean-Christophe Filliâtre. Type-Safe Modular Hash-Consing. In ACM SIGPLAN Workshop on ML, Portland, Oregon, September 2006.
https://www.lri.fr/~filliatr/ftp/publis/hash-consing2.pdf
Note: a different, more elaborated hash-consing library can be found in Why3 sources at https://gitlab.inria.fr/why3/why3