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.1 required=5.0 tests=AWL,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 concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by yquem.inria.fr (Postfix) with ESMTP id 3C030BC0A for ; Mon, 12 Mar 2007 22:35:49 +0100 (CET) Received: from wr-out-0506.google.com (wr-out-0506.google.com [64.233.184.233]) by concorde.inria.fr (8.13.6/8.13.6) with ESMTP id l2CLZkhb030965 for ; Mon, 12 Mar 2007 22:35:47 +0100 Received: by wr-out-0506.google.com with SMTP id 50so791921wra for ; Mon, 12 Mar 2007 14:35:46 -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=ayNoxrzh0xET14MERD8SoQSPt87RrAwutgC65OJqD+qYXvKMTWzIgrst9sYoDfc1hAJeK+Yw7GY2wACy03H4o3C/VFybqZcVQtJ52z4nAvlT4j5SCywAZ39wHojHFo4uO/r+0A3tfPriJPlBw55W7U58o4U3vEuNUUyqOo0fXEc= 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=UsBS8N7M1ryDswjMxMvEj1/5iIdjwCmd4jaYZps72PBeb4iL0F086Wok9CWBZ3xV4OF2lQjnNXKBsfEqenP/ghlna4tVi8U7cCn6JJrihtvnEzoaUNzqMf5jlKvX9Nuo92jhP6xd7pDuYTCarfPL05goW8RuRmF3fX49qQ5a54s= Received: by 10.65.236.14 with SMTP id n14mr326956qbr.1173735346033; Mon, 12 Mar 2007 14:35:46 -0700 (PDT) Received: by 10.65.100.8 with HTTP; Mon, 12 Mar 2007 14:35:45 -0700 (PDT) Message-ID: <9d3ec8300703121435i6413c32fyacee77038bf6c08a@mail.gmail.com> Date: Mon, 12 Mar 2007 22:35:45 +0100 From: "Till Varoquaux" To: "Chris King" Subject: Re: [Caml-list] coercions issues Cc: "ocaml ml" In-Reply-To: <875c7e070703121411g33ad1c86k5de33e2dd5fbf239@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> <875c7e070703121411g33ad1c86k5de33e2dd5fbf239@mail.gmail.com> X-j-chkmail-Score: MSGID : 45F5C7B2.004 on concorde : j-chkmail score : X : 0/20 1 0.000 -> 1 X-Miltered: at concorde with ID 45F5C7B2.004 by Joe's j-chkmail (http://j-chkmail . ensmp . fr)! X-Spam: no; 0.00; coercions:01 sould:01 monadic:01 monadic:01 supertype:01 cheers:01 coerced:01 expr:01 expr:01 binop:01 binop:01 unop:01 unop:01 mutable:01 o'caml:01 Great! That was indeed really helpfull! I really missed out that last bit, I sould have payed more attention. 'a Mon.m and 'a O.m are monadic values. O.m and Mon.m are the same type. My intuition would be that they should be variant ((a :> b m) should behave like a >>= (fun x -> return (x:>b) where a is a value m a monadic type and b a supertype of a)) can anyone concur that. Cheers, Till On 3/12/07, Chris King wrote: > 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 >