From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.1.3 (2006-06-01) on yquem.inria.fr X-Spam-Level: * X-Spam-Status: No, score=1.4 required=5.0 tests=SPF_NEUTRAL autolearn=disabled version=3.1.3 X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from discorde.inria.fr (discorde.inria.fr [192.93.2.38]) by yquem.inria.fr (Postfix) with ESMTP id 2E234BC0A for ; Mon, 12 Mar 2007 22:11:41 +0100 (CET) Received: from an-out-0708.google.com (an-out-0708.google.com [209.85.132.242]) by discorde.inria.fr (8.13.6/8.13.6) with ESMTP id l2CLBdpZ024380 for ; Mon, 12 Mar 2007 22:11:40 +0100 Received: by an-out-0708.google.com with SMTP id d26so1468700and for ; Mon, 12 Mar 2007 14:11:39 -0700 (PDT) DKIM-Signature: a=rsa-sha1; c=relaxed/relaxed; d=gmail.com; s=beta; h=domainkey-signature:received:received:message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=NpPauRPD6H9KpHe/FKAQZwoYfOwCSk6qWoYoZQvqCeEh1lAKZtUdQPr1xnHIdvyOS72Br1wC4G2C41IIE4VZ3rh3+smh7M4sSJuQHr4zTPbW+NuPZYVh3ZDjMuU7Hurou/xgwsJaN2swB+pExHepABCYxReyNMlmPXx+YAlUnQw= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=beta; h=received:message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=dC9kH/qOmuHPcTc3evAXM3aA3+j1U9eapJc/8cXWXsdzz18KDte2wSHYHOQCuYhWIjIT+qiXxAIsAFlFhrTPNg9IetLw+Lu8eZY0yRUvOfo2Qk489VSyZCTUYN7Q8JN9REr+X6Xj8JHE3rx+u4TQoObiCUeZpKd+amEHp3W7UFY= Received: by 10.114.81.1 with SMTP id e1mr2082339wab.1173733898030; Mon, 12 Mar 2007 14:11:38 -0700 (PDT) Received: by 10.114.241.6 with HTTP; Mon, 12 Mar 2007 14:11:37 -0700 (PDT) Message-ID: <875c7e070703121411g33ad1c86k5de33e2dd5fbf239@mail.gmail.com> Date: Mon, 12 Mar 2007 16:11:37 -0500 From: "Chris King" To: "Till Varoquaux" Subject: Re: [Caml-list] coercions issues Cc: "ocaml ml" In-Reply-To: <9d3ec8300703121311h32b09b1by2955d658238d8a02@mail.gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline References: <9d3ec8300703121311h32b09b1by2955d658238d8a02@mail.gmail.com> X-j-chkmail-Score: MSGID : 45F5C20B.002 on discorde : j-chkmail score : X : 0/20 1 0.000 -> 1 X-Miltered: at discorde with ID 45F5C20B.002 by Joe's j-chkmail (http://j-chkmail . ensmp . fr)! X-Spam: no; 0.00; coercions:01 coerced:01 expr:01 expr:01 binop:01 binop:01 unop:01 unop:01 mutable:01 o'caml:01 subtype:01 subtype:01 epos:98 epos:98 wrote:01 On 3/12/07, Till Varoquaux wrote: > This expression cannot be coerced to type > O.o Ast.T.expr O.m = O.o Ast.T.expr Mon.m; > it has type O.o Ast_js.T.expr Mon.m but is here used with type > O.o Ast.T.expr O.m = O.o Ast.T.expr Mon.m > Type > O.o Ast_js.T.expr = > [ `Binop of To.binop * To.expr * To.expr > | `Cst of To.constant > | `Ecall of To.ident * To.arg list > | `Fun of To.ident list * To.bloc > | `Lval of To.lvalue > | `Unop of To.unop * To.expr ] > is not compatible with type > O.o Ast.T.expr = > [ `Binop of To.binop * To.expr * To.expr > | `Cst of To.constant > | `Ecall of To.ident * To.arg list > | `Epos of Ast.location * To.expr > | `Fun of To.ident list * To.bloc > | `Lval of To.lvalue > | `Unop of To.unop * To.expr ] > The first variant type does not allow tag(s) `Epos What sort of type is 'a O.m (or 'a Mon.m)? If it's something whose 'a member is mutable, then such a coercion will be impossible (it would allow you to set the member to have the `Epos tag, which it can't). This would also happen if 'a O.m is declared as an abstract type, since O'Caml assumes invariance by default. In the latter case, you need to specify that 'a O.m is covariant with its parameter: type +'a O.m This tells Caml that if 'a is a subtype of 'b, then 'a O.m is indeed a subtype of 'b O.m and you will be allowed to perform the above coercion. Hope this helps. - Chris