From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from majordomo@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id SAA25174; Wed, 16 Apr 2003 18:01:30 +0200 (MET DST) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f Received: (from xleroy@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id SAA25226 for caml-list@pauillac.inria.fr; Wed, 16 Apr 2003 18:01:29 +0200 (MET DST) Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id NAA11702 for ; Tue, 15 Apr 2003 13:12:49 +0200 (MET DST) Received: from greendale.ukc.ac.uk (greendale.ukc.ac.uk [129.12.21.13]) by nez-perce.inria.fr (8.11.1/8.11.1) with ESMTP id h3FBCn926312 for ; Tue, 15 Apr 2003 13:12:49 +0200 (MET DST) Received: from myrtle.ukc.ac.uk ([129.12.3.176] ident=root) by greendale.ukc.ac.uk with esmtp (Exim 3.22 #4) id 195OMj-0001wf-00 for caml-list@inria.fr; Tue, 15 Apr 2003 12:12:41 +0100 Received: from as49 by myrtle.ukc.ac.uk with local (Exim 3.36 #1) id 195OMj-0006RM-00 for caml-list@inria.fr; Tue, 15 Apr 2003 12:12:41 +0100 Date: Tue, 15 Apr 2003 12:12:41 +0100 From: Axel Simon To: caml-list@inria.fr Subject: [Caml-list] polymorphic modules in classes Message-ID: <20030415111241.GB20789@myrtle.ukc.ac.uk> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.4i X-UKC-Mail-System: No virus detected X-Spam: no; 0.00; hashtbl:01 generic:01 hash:01 hashedtype:01 struct:01 outch:01 bin:01 ocaml:01 equality:01 int:01 polymorphic:01 compile:02 modules:02 unbound:02 module:03 X-Spam: no; 0.00; hashtbl:01 generic:01 hash:01 hashedtype:01 struct:01 outch:01 bin:01 ocaml:01 equality:01 int:01 polymorphic:01 compile:02 modules:02 unbound:02 module:03 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk Hi, I would like to use a Hashtbl which is polymorphic in its elements. The elements should by compared by physical equality so I cannot use the "generic interface". My goal is to create a hash table over the type 'a which maps to int. I wrote: module H = Hashtbl;; module PhysEq : H.HashedType = struct type t let equal = (==) let hash = H.hash end;; module PhysHashtbl : H.S = H.Make(PhysEq);; class ['a] bulkWriter ((fname, wr) : string * (out_channel -> 'a -> unit)) = let outCh = open_out_bin fname and stored : (a' PhysHashtbl.t) = (PhysHashtbl.create 100) in object (* something here *) end When I compile, I get "Unbound type constructor a'" for the line which introduces stored, although it works with int. I guess there are many other problems with my solution: PhysEq.t is abstract and PhysHashtbl.key is not bound to any type. How do I solve all this? I am really new to OCaml and I couldn't make sense of the tutorials and other messages posted on this list. Any help appreciated, Axel. ------------------- To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/ Beginner's list: http://groups.yahoo.com/group/ocaml_beginners