Date: Fri, 11 Apr 1997 10:05:21 +0200
Message-Id: <199704110805.KAA04329@arthur.u-strasbg.fr>
From: Christian Boos <boos@arthur.u-strasbg.fr>
To: caml-list@inria.fr
Subject: Re: Q: hashtables of parametrized types in Ocaml?
In-Reply-To: <199704041903.OAA17096@gulag.cs.cornell.edu>
<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
This archive was generated by hypermail 2b29 : Sun Jan 02 2000 - 11:58:10 MET