Or you can also functorize your own piece of code :
module Make (A : sig type t end) =
struct
module rec H :
sig
type 'a node =
| Node of 'a node J.t
| Leaf of 'a
type t = A.t node
val equal : t -> t -> bool
val hash : t -> int
end =
struct
type 'a node =
| Node of 'a node J.t
| Leaf of 'a
type t = A.t node
let equal = (==)
let hash = Hashtbl.hash
end
and J : Hashtbl.S with type key = A.t H.node = Hashtbl.Make( H )
end
David Teller wrote:If I understand you correctly I would have to redefine equivalents for:
It's probably feasible without copy & paste by building a functor on top
of the defunctorized hashtable in Batteries. Or by just using the
defunctorized hashtable of Batteries directly, although it's not as safe
as the functorized version, due to the absence of existential types.
- HashedType
- S
- Make(H: HashedType)
Basically copy & paste these and change the type.
Doable although not to my liking.
TIA,
Hugo F.
Cheers,
David
On Tue, 2009-01-20 at 12:24 +0100, Daniel Bünzli wrote:
Le 20 janv. 09 à 11:59, Hugo Ferreira a écrit :
Is it possible to make H comply with Hashtbl.HashedType i.e: makeThis issue is well known (e.g. see here [1]). Your are running into limitations of the standard library. The only unsatisfying answer is to copy the code from the standard library and add the parameter yourself.
J.Key = 'a H.node ?
Best,
Daniel
[1] http://groups.google.com/group/fa.caml/browse_thread/thread/f2acb593da91553c?hl=fr&ie=UTF-8&q=type+var+in+functor+fa.caml
____________________________________________ugs
_______________________________________________
Caml-list mailing list. Subscription management:
http://yquem.inria.fr/cgi-bin/mailman/listinfo/caml-list
Archives: http://caml.inria.fr
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
Bug reports: http://caml.inria.fr/bin/caml-bugs