Date: Fri, 11 Apr 1997 10:05:21 +0200
From: Christian Boos <firstname.lastname@example.org>
Subject: Re: Q: hashtables of parametrized types in Ocaml?
Mark Hayden writes:
> Here is a similar example that works for me.
> This is for hash tables that use MD5 digest
> strings for keys.
> <<.mli and .ml snipped>>
I don't think this was an example similar to the original post.
What Basile needed was a parametrized type for the key type:
> >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.
module MakeHashtbl (S : sig type v end) =
type t = S.v asymbol_t
let equal = (==)
let hash = symhash
and then later:
module NodeSymbolHashtbl = MakeHashtbl (sig type v = node_t end)
This archive was generated by hypermail 2b29 : Sun Jan 02 2000 - 11:58:10 MET