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 LAA31205; Mon, 10 Dec 2001 11:13:05 +0100 (MET) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id LAA31060 for ; Mon, 10 Dec 2001 11:13:04 +0100 (MET) Received: from d12lmsgate.de.ibm.com (d12lmsgate.de.ibm.com [195.212.91.199]) by concorde.inria.fr (8.11.1/8.11.1) with ESMTP id fBAAD3520601 for ; Mon, 10 Dec 2001 11:13:03 +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 LAA259854 for ; Mon, 10 Dec 2001 11:13:02 +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 fBAADRk167846 for ; Mon, 10 Dec 2001 11:13:27 +0100 Importance: Normal Subject: Re: [Caml-list] mutability analysis too strict? To: 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 12:13:19 +0200 X-MIMETrack: Serialize by Router on D10ML001/10/M/IBM(Release 5.0.8 |June 18, 2001) at 10/12/2001 12:13:22 MIME-Version: 1.0 Content-type: text/plain; charset=us-ascii Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk > Sent by: owner-caml-list@pauillac.inria.fr > To: caml-list@inria.fr > cc: > Subject: Re: [Caml-list] mutability analysis too strict? > "Ohad Rodeh" writes: > > First of all, sorry my mail was sent twice, this was due to mail delivery > > 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 = sig > > val put : 'a -> 'b -> unit > > val get : 'a -> 'b > > end > > > > An implementation that looks like this: > > > > module S : Repos = struct > > let h = Hashtbl.create 10 > > let put key data = Hashtbl.add h key data > > let get key = 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 this > > 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. Remi VANICAT @pauillac.inria.fr on 10/12/2001 11:28:42 > it's dangerous. Imagine you can do : > > put 2 "xd" > > what will be the type of : > > get 2 > > how the type inference algorithm can know that it is a string ? it > can't because you can do something like : > > if x < y then put 2 "xd" > else put 2 5 > > and then, the type of get 2 wil be string or int depending on the fact > that x was less than y or not. Well, that's a strong argument ... How do you propose building a repository of polymorphic values then? Ohad. ------------------- 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