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 KAA29959; Mon, 10 Dec 2001 10:28:54 +0100 (MET) 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 KAA29897 for ; Mon, 10 Dec 2001 10:28:53 +0100 (MET) Received: from serveur3.labri.fr (serveur3.labri.u-bordeaux.fr [147.210.8.180]) by nez-perce.inria.fr (8.11.1/8.11.1) with ESMTP id fBA9SiH02995 for ; Mon, 10 Dec 2001 10:28:48 +0100 (MET) Received: (from vanicat@localhost) by serveur3.labri.fr (8.11.6/8.11.6) id fBA9Sh318077; Mon, 10 Dec 2001 10:28:43 +0100 X-Authentication-Warning: serveur3.labri.fr: vanicat set sender to vanicat@labri.u-bordeaux.fr using -f To: caml-list@inria.fr Subject: Re: [Caml-list] mutability analysis too strict? References: From: Remi VANICAT In-Reply-To: Date: 10 Dec 2001 10:28:42 +0100 Message-ID: User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.0.104 MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk "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. 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. -- Rémi Vanicat vanicat@labri.u-bordeaux.fr http://dept-info.labri.u-bordeaux.fr/~vanicat ------------------- 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