From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Delivered-To: caml-list@yquem.inria.fr Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by yquem.inria.fr (Postfix) with ESMTP id 8C0D7BB81 for ; Wed, 8 Dec 2004 15:23:40 +0100 (CET) Received: from pauillac.inria.fr (pauillac.inria.fr [128.93.11.35]) by nez-perce.inria.fr (8.13.0/8.13.0) with ESMTP id iB8ENeCB018009 for ; Wed, 8 Dec 2004 15:23:40 +0100 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 PAA11398; Wed, 8 Dec 2004 15:23:39 +0100 (MET) Received: from kurims.kurims.kyoto-u.ac.jp (kurims.kurims.kyoto-u.ac.jp [130.54.16.1]) by concorde.inria.fr (8.13.0/8.13.0) with ESMTP id iB8ENcJF020084; Wed, 8 Dec 2004 15:23:39 +0100 Received: from localhost (suiren [130.54.16.25]) by kurims.kurims.kyoto-u.ac.jp (8.13.1/8.13.1) with ESMTP id iB8ENbvS019765; Wed, 8 Dec 2004 23:23:37 +0900 (JST) Date: Wed, 08 Dec 2004 23:23:22 +0900 (JST) Message-Id: <20041208.232322.07401394.garrigue@math.nagoya-u.ac.jp> To: Alain.Frisch@inria.fr Cc: caml-list@inria.fr Subject: Re: [Caml-list] Type constraints From: Jacques Garrigue In-Reply-To: <41B6F610.8000507@inria.fr> References: <41B62407.4020102@inria.fr> <74A16EF6-4907-11D9-8195-000D9345235C@inria.fr> <41B6F610.8000507@inria.fr> X-Mailer: Mew version 4.0.64 on Emacs 21.3 / Mule 5.0 (SAKAKI) Mime-Version: 1.0 Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Miltered: at nez-perce with ID 41B70E6C.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Miltered: at concorde with ID 41B70E6A.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Spam: no; 0.00; caml-list:01 frisch:01 frisch:01 damien:01 wrote:01 hmmm:01 nonexpansive:01 texp:01 letmodule:01 nonexpansive:01 struct:01 inference:01 ...:98 ...:98 doligez:01 X-Spam-Checker-Version: SpamAssassin 3.0.0 (2004-09-13) on yquem.inria.fr X-Spam-Status: No, score=0.0 required=5.0 tests=none autolearn=disabled version=3.0.0 X-Spam-Level: From: Alain Frisch > Damien Doligez wrote: > > Hmmm... Now I don't know whether it's safe or not, and I don't know > > whether someone checked its safety before excluding it from the value > > restriction code... > > With this extra line added to is_nonexpansive: > > | Texp_letmodule (_,_,e) -> is_nonexpansive e > > we get: > > # let module M = struct let x = ref [] end in M.x;; > - : 'a list ref = {contents = []} > > The non-generalizable status has been forgotten. What I'm not sure is > whether this is only an artefact of the internal representation of > levels to control generalization, or whether there are some deeper issues. It's not really an artefact, just that there is no such thing as a non-generalizable status: something that is not generalizable in some context becomes generalizable in a larger context. So you cannot rely on the generalizability obtained during the typing of the module. Rather you must check whether the module itself contains only non-expansive definitions. I.e. you cannot ignore the definition of the module, as you are doing here. Yet, modules are strange beasts for typing, so I wouldn't add the code before thinking it through. (Note that there is another way to handle non-generalizability, without relying on a non-expansiveness predicate, raising the non-generalizable level only when entering functions, and that might solve the problem for free. Francois Pottier told me he was using it. However it requires many small changes to type inference, and doesn't mix well with the new "relaxed" value restriction.) Jacques Garrigue