caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* Making a polymorphic type non-polymorphic to comply with original signature
@ 2009-01-20 10:59 Hugo Ferreira
  2009-01-20 11:24 ` [Caml-list] " Daniel Bünzli
  2009-01-20 15:01 ` Martin Jambon
  0 siblings, 2 replies; 9+ messages in thread
From: Hugo Ferreira @ 2009-01-20 10:59 UTC (permalink / raw)
  To: caml-list

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.





^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2009-01-20 17:05 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-01-20 10:59 Making a polymorphic type non-polymorphic to comply with original signature Hugo Ferreira
2009-01-20 11:24 ` [Caml-list] " Daniel Bünzli
2009-01-20 11:37   ` David Teller
2009-01-20 11:46     ` Hugo Ferreira
2009-01-20 12:56       ` Thomas Gazagnaire
2009-01-20 13:25         ` Hugo Ferreira
2009-01-20 11:43   ` Hugo Ferreira
2009-01-20 15:01 ` Martin Jambon
2009-01-20 17:05   ` Hugo Ferreira

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).