From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Original-To: caml-list@yquem.inria.fr 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 4C2E8BB94 for ; Mon, 3 Oct 2005 15:54:37 +0200 (CEST) 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 j93DsalY003114 for ; Mon, 3 Oct 2005 15:54:36 +0200 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 PAA31015 for ; Mon, 3 Oct 2005 15:54:35 +0200 (MET DST) Received: from kurims.kurims.kyoto-u.ac.jp (kurims.kurims.kyoto-u.ac.jp [130.54.16.1]) by nez-perce.inria.fr (8.13.0/8.13.0) with ESMTP id j93DsXvZ003111 for ; Mon, 3 Oct 2005 15:54:34 +0200 Received: from localhost (suiren [130.54.16.25]) by kurims.kurims.kyoto-u.ac.jp (8.13.1/8.13.1) with ESMTP id j93DsPxU006668; Mon, 3 Oct 2005 22:54:27 +0900 (JST) Date: Mon, 03 Oct 2005 16:55:19 +0300 (EEST) Message-Id: <20051003.165519.18311666.garrigue@math.nagoya-u.ac.jp> To: cstork@ics.uci.edu Cc: caml-list@inria.fr Subject: Re: [Caml-list] Using Polymorphic Variants From: Jacques Garrigue In-Reply-To: <20051002164508.GA1686@anthony.ics.uci.edu> References: <20051002000609.GA30761@anthony.ics.uci.edu> <433F9DBE.6020509@gaillourdet.net> <20051002164508.GA1686@anthony.ics.uci.edu> X-Mailer: Mew version 4.2 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 4341381C.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Miltered: at nez-perce with ID 43413819.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Spam: no; 0.00; caml-list:01 variants:01 variants:01 coerced:01 undecidable:01 subtyping:01 subtyping:01 recursive:01 ...:98 ...:98 wrote:01 polymorphic:01 polymorphic:01 simpler:01 algorithm:01 X-Spam-Checker-Version: SpamAssassin 3.0.3 (2005-04-27) on yquem.inria.fr X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=none autolearn=disabled version=3.0.3 From: Christian Stork > On Sun, Oct 02, 2005 at 10:43:42AM +0200, Jean-Marie Gaillourdet wrote: > > Christian Stork schrieb: > > > Basic Question: > > > > Why aren't polymorphic variants coerced by default? > > > I guess there is some undecidability involved. > > My guess too, but I'd like to be sure. ;-) Not really undecidable, but you would have to completely change the way types are inferred, and accept type schemes with subtyping constraints (cf. HM(X)). Keeping all the subtyping explicit makes things simpler. So there is no plan to change this. > > > ... f (x: type_of_x :> type_expected_by_f) ... > > Isn't it possible to write something like that: > > (f: 'a) (x: type_of_x :> 'a) The subtyping algorithm only looks at explicit types, so the sharing of 'a has no effect. In simple cases (with no recursive types), the following will work: (c : type_of_x :> [> type_of_x ]) Jacques Garrigue