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 concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by yquem.inria.fr (Postfix) with ESMTP id 2099DBB83 for ; Fri, 5 May 2006 10:03:45 +0200 (CEST) Received: from pauillac.inria.fr (pauillac.inria.fr [128.93.11.35]) by concorde.inria.fr (8.13.0/8.13.0) with ESMTP id k4583iwQ022908 for ; Fri, 5 May 2006 10:03:44 +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 KAA24312 for ; Fri, 5 May 2006 10:03:44 +0200 (MET DST) Received: from mcr-smtp-002.bulldogdsl.com (mcr-smtp-002.bulldogdsl.com [212.158.248.8]) by nez-perce.inria.fr (8.13.0/8.13.0) with ESMTP id k4583hv6003173 for ; Fri, 5 May 2006 10:03:43 +0200 Received: by mcr-smtp-002.bulldogdsl.com (Postfix, from userid 1010) id 54374845A84; Fri, 5 May 2006 09:03:43 +0100 (BST) Received: from [192.168.123.123] (host-84-9-232-199.bulldogdsl.com [84.9.232.199]) by mcr-smtp-002.bulldogdsl.com (Postfix) with ESMTP id 0B9F8845AE9 for ; Fri, 5 May 2006 09:03:42 +0100 (BST) Message-ID: <445B06F1.2040901@sms.ed.ac.uk> Date: Fri, 05 May 2006 09:04:01 +0100 From: Jeremy Yallop User-Agent: Mozilla Thunderbird 1.0.7 (X11/20051013) X-Accept-Language: en-us, en MIME-Version: 1.0 To: caml-list@inria.fr Subject: Re: [Caml-list] Oddness with recursive polymorphic variants References: <445A22BA.4070807@sms.ed.ac.uk> <20060504210319.5e05f7a6.nils.gesbert@ens.fr> In-Reply-To: <20060504210319.5e05f7a6.nils.gesbert@ens.fr> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Miltered: at concorde with ID 445B06E0.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Miltered: at nez-perce with ID 445B06DF.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Spam: no; 0.00; recursive:01 variants:01 rhs:01 annotation:01 compiler:01 annotation:01 polymorphic:01 caml-list:01 coercion:01 patterns:01 parameter:02 parameters:02 clash:02 types:02 sms:96 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 Thanks for all the replies. My current understanding is as follows: Given the types type f = [`A] type g = [f | `C] then the following function is not acceptable let k (x:f) = (x:g) because f and g are not unifiable: they are "closed rows" with different fields. There are a number of ways to "open" the row, however: let k (#f as x:f) = (x:g) This one is acceptable because the pattern "#f" means "an open row that includes all the tags in f". (That's its type on the rhs, anyway. The pattern (and the function) will accept exactly those tags in the type "f"). The type annotation on the parameter doesn't affect the type of "x", although the compiler does check that the type of the annotation and of the pattern can be unified. The case where all the tags (only one in this case) are enumerated is treated identically: let k (`A as x:f) = (x:g) Finally, the explicit coercion (:>). Like the acceptable patterns, this "opens" the row, allowing it to be unified with "g" (or, indeed, with any other row type whose tag parameters don't clash with those of "f"). How does that sound? Jeremy.