caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* Defining type that requires hashtables with recursive definition
@ 2009-01-19 17:26 Hugo Ferreira
  2009-01-19 17:34 ` [Caml-list] " Jacques Carette
  0 siblings, 1 reply; 6+ messages in thread
From: Hugo Ferreira @ 2009-01-19 17:26 UTC (permalink / raw)
  To: caml-list

Hello,

I am attempting to define a type so:

type node =
   | Node of links
   | Leaf of int

And I want to implement links as a
hashtable whose keys and values are
also of type node. Note that the idea
is to use object address comparison
for the keys so:

module H =
   struct
     type t = node
     let equal (e1:node) (e2:node) = (==) e1 e2
     let hash (e:node) = Hashtbl.hash e
   end

module J = Hashtbl.Make( H )

However this requires a recursive definition on
the hashtable. How may a declare node and hashtable
to allow this?

TIA,
Hugo F.




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

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

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-01-19 17:26 Defining type that requires hashtables with recursive definition Hugo Ferreira
2009-01-19 17:34 ` [Caml-list] " Jacques Carette
2009-01-19 18:03   ` Thomas Gazagnaire
2009-01-19 19:36     ` Hugo Ferreira
2009-01-20 10:09     ` Hugo Ferreira
2009-01-19 19:34   ` 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).