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 KAA29606; Mon, 10 Dec 2001 10:12:46 +0100 (MET) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f 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 KAA29601 for ; Mon, 10 Dec 2001 10:12:45 +0100 (MET) Received: from d12lmsgate.de.ibm.com (d12lmsgate.de.ibm.com [195.212.91.199]) by nez-perce.inria.fr (8.11.1/8.11.1) with ESMTP id fBA9ChH02284; Mon, 10 Dec 2001 10:12:43 +0100 (MET) Received: from d12relay02.de.ibm.com (d12relay02.de.ibm.com [9.165.215.23]) by d12lmsgate.de.ibm.com (1.0.0) with ESMTP id KAA32434; Mon, 10 Dec 2001 10:12:37 +0100 Received: from d10hubm1.telaviv.ibm.com (d10ml001.telaviv.ibm.com [9.148.216.55]) by d12relay02.de.ibm.com (8.11.1m3/NCO v5.01) with ESMTP id fBA9D2k36336; Mon, 10 Dec 2001 10:13:02 +0100 Importance: Normal Subject: Re: [Caml-list] mutability analysis too strict? To: Francois.Pottier@inria.fr Cc: caml-list@inria.fr X-Mailer: Lotus Notes Release 5.0.7 March 21, 2001 Message-ID: From: "Ohad Rodeh" Date: Mon, 10 Dec 2001 11:12:39 +0200 X-MIMETrack: Serialize by Router on D10ML001/10/M/IBM(Release 5.0.8 |June 18, 2001) at 10/12/2001 11:12:56 MIME-Version: 1.0 Content-type: text/plain; charset=iso-8859-1 Content-transfer-encoding: quoted-printable Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk First of all, sorry my mail was sent twice, this was due to mail delive= ry problems from my site. Perhaps I was not specific enough about what I wanted to acheive. What = I need is a repository that has the following interface: module type Repos =3D sig val put : 'a -> 'b -> unit val get : 'a -> 'b end An implementation that looks like this: module S : Repos =3D struct let h =3D Hashtbl.create 10 let put key data =3D Hashtbl.add h key data let get key =3D Hashtbl.find h key end Does not work. Compilation error: Signature mismatch: Modules do not match: sig val h : ('_a, '_b) Hashtbl.t val put : '_a -> '_b -> unit val get : '_a -> '_b end is not included in Repos Values do not match: val put : '_a -> '_b -> unit is not included in val put : 'a -> 'b -> unit I tried also using the Map and Set modules, but they don't really allow= building a repository of immutable values either. Is there any deep reason for t= his behavior? Could you expound on this line: > A monomorphic, mutable > structure that contains polymorphic data is sound, but cannot be expressed > in ML's type system where universal quantification must be prenex. Ohad. Francois Pottier @pauillac.inria.fr on 10/12/2001 10:13:31 Please respond to Francois.Pottier@inria.fr Sent by: owner-caml-list@pauillac.inria.fr To: Ohad Rodeh/Haifa/IBM@IBMIL cc: caml-list@inria.fr Subject: Re: [Caml-list] mutability analysis too strict? On Sun, Dec 09, 2001 at 05:43:41PM +0200, Ohad Rodeh wrote: > > let h =3D Hashtbl.create 10;; > h : ('_a, '_b) Hashtbl.t > > The objects and keys in the table are infered to be mutable. However,= > in my case, they are immutable and I have to coerce them using Obj.ma= gic > from '_b to 'b. You are slightly wrong here: the analysis infers the table itself (not = the keys or objects in it) to be mutable, which it indeed is. If the table = was given a polymorphic type, you would be able to store objects of a certa= in type and to retrieve them at another type (by taking different instance= s of 'b), which would be unsound. Furthermore, I'm surprised to hear that using Obj.magic helps; indeed, = any application of Obj.magic is itself deemed `dangerous' by O'Caml, leadin= g to the following behavior: # let h =3D Hashtbl.create 10;; val h : ('_a, '_b) Hashtbl.t =3D # let h =3D (Obj.magic h : ('a, 'b) Hashtbl.t);; val h : ('_a, '_b) Hashtbl.t =3D That is, Obj.magic doesn't help at all in this case. Perhaps you could tell us what you are trying to achieve? Any polymorph= ic, mutable structure is unsound and rightly rejected. A monomorphic, mutab= le structure that contains polymorphic data is sound, but cannot be expres= sed in ML's type system where universal quantification must be prenex. -- Fran=E7ois Pottier Francois.Pottier@inria.fr http://pauillac.inria.fr/~fpottier/ ------------------- Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/ 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/ To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr