Mailing list for all users of the OCaml language and system.
 help / color / mirror / Atom feed
From: Christian Boos <boos@arthur.u-strasbg.fr>
To: caml-list@inria.fr
Cc: Basile.Starynkevitch@cea.fr, Mark Hayden <hayden@cs.cornell.edu>
Subject: Re: Q: hashtables of parametrized types in Ocaml?
Date: Fri, 11 Apr 1997 10:05:21 +0200	[thread overview]
Message-ID: <199704110805.KAA04329@arthur.u-strasbg.fr> (raw)
In-Reply-To: <199704041903.OAA17096@gulag.cs.cornell.edu>

Mark Hayden writes:
 > 
 > Here is a similar example that works for me.
 > This is for hash tables that use MD5 digest 
 > strings for keys.
 > 
 > --Mark
 > <<.mli and .ml snipped>>

	Hello, 

  I don't think this was an example similar to the original post. 
What Basile needed was a parametrized type for the key type:

He wrote:
 > >I tried 
 > >
 > >    module SymbolHashtbl =
 > >      Hashtbl.Make(struct
 > >	type t = 'a asymbol_t
 > >	let equal = (==)
 > >	let hash = symhash
 > >      end)
 > >
 > >but it doesn't work! How can I achieve an equivalent result? Of course
 > > <<...>>
 > >Perhaps a double functor is the answer, but I can't figure it out!

I think his idea of a "double functor" is the good one.


Try:

    module MakeHashtbl (S : sig type v end) =
      Hashtbl.Make 
        (struct
          type t = S.v asymbol_t
          let equal = (==)
          let hash = symhash
        end)


and then later:

    module NodeSymbolHashtbl = MakeHashtbl (sig type v = node_t end)


-- Christian





      reply	other threads:[~1997-04-11  9:17 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1997-04-04 11:44 Basile STARYNKEVITCH
1997-04-04 19:03 ` Mark Hayden
1997-04-11  8:05   ` Christian Boos [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=199704110805.KAA04329@arthur.u-strasbg.fr \
    --to=boos@arthur.u-strasbg.fr \
    --cc=Basile.Starynkevitch@cea.fr \
    --cc=caml-list@inria.fr \
    --cc=hayden@cs.cornell.edu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox