Version française
Home     About     Download     Resources     Contact us    
Browse thread
Making a polymorphic type non-polymorphic to comply with original signature
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Hugo Ferreira <hmf@i...>
Subject: Making a polymorphic type non-polymorphic to comply with original signature
Hello,

I have the following definition:

module rec H :
   sig
       type 'a node =
           | Node of 'a node J.t
           | Leaf of 'a

      type 'a t = 'a node
      val equal : 'a t -> 'a t -> bool
     val hash : 'a t -> int
   end =
struct
     type 'a node =
         | Node of 'a node J.t
         | Leaf of 'a

     type 'a t = 'a node
     let equa = (==)
     let hash = Hashtbl.hash
end

and J : Hashtbl.S with type 'a key = 'a H.node = Hashtbl.Make( H )
;;

The data type 'a node is polymorphic. It is also a key used by the
hash-table. Note that H now does not comply with Hashtbl.HashedType
(because Hashtbl.HashedType is not polymorphic). By adding the
constraint "with type" also does not help.

Is it possible to make H comply with Hashtbl.HashedType i.e: make
J.Key = 'a H.node ?

TIA,
Hugo F.