Module Hashcons

Generic hash-consing.

Hashconsing functorial interface
module type HashconsedType = sig ... end
module type S = sig ... end
module Make : functor (X : HashconsedType) -> S with type t = X.t and type u = X.u

Create a new hashconsing, given canonicalization functions.

Wrappers
val simple_hcons : ('u -> 'tab) -> ('tab -> 't -> 't) -> 'u -> 't -> 't

simple_hcons f sub obj creates a new table each time it is applied to any sub-hash function sub.

val recursive_hcons : ((('t -> 't) * 'u) -> 'tab) -> ('tab -> 't -> 't) -> 'u -> 't -> 't

As simple_hcons but intended to be used with well-founded data structures.

Hashconsing of usual structures
module type HashedType = sig ... end
module Hstring : S with type t = string and type u = unit

Hashconsing of strings.

module Hlist : functor (D : HashedType) -> S with type t = D.t list and type u = (D.t list -> D.t list) * (D.t -> D.t)

Hashconsing of lists.