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 B4A0CBB83 for ; Thu, 4 May 2006 20:24:20 +0200 (CEST) Received: from mail.gmx.net (mail.gmx.de [213.165.64.20]) by concorde.inria.fr (8.13.0/8.13.0) with SMTP id k44IOJ5w020819 for ; Thu, 4 May 2006 20:24:20 +0200 Received: (qmail invoked by alias); 04 May 2006 18:24:19 -0000 Received: from p54A34719.dip0.t-ipconnect.de (EHLO [192.168.2.136]) [84.163.71.25] by mail.gmx.net (mp041) with SMTP; 04 May 2006 20:24:19 +0200 X-Authenticated: #20477425 From: Michael Wohlwend To: caml-list@yquem.inria.fr Subject: Re: [Caml-list] Oddness with recursive polymorphic variants Date: Thu, 4 May 2006 20:26:23 +0200 User-Agent: KMail/1.9.1 References: <445A23BF.4030001@sms.ed.ac.uk> <20060504171010.GB23421@yquem.inria.fr> In-Reply-To: <20060504171010.GB23421@yquem.inria.fr> X-Face: S)[vu%Bha1d&ej9GfwAq~7C}A,y[B.uS}+D6'hb~xPwsxymw$fnCOaMe<=?utf-8?q?*bnUajSBR=5Fm=3FR=0A=09?=@V3;iX8[A}z`.%pEQ1r7iZhN8#ktTCBQ}&mkx>=RH&l|l6\]NZI@ MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200605042026.23763.micha-1@fantasymail.de> X-Y-GMX-Trusted: 0 X-Miltered: at concorde with ID 445A46D3.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Spam: no; 0.00; recursive:01 variants:01 maranget:01 compiler:01 2006:98 squad:98 cigarette:98 blindfold:98 wrote:01 luc:01 polymorphic:01 polymorphic:01 caml-list:01 variant:02 match:02 X-Spam-Checker-Version: SpamAssassin 3.0.3 (2005-04-27) on yquem.inria.fr X-Spam-Level: X-Spam-Status: No, score=0.1 required=5.0 tests=FORGED_RCVD_HELO,SPF_FAIL autolearn=disabled version=3.0.3 On Thursday 04 May 2006 19:10, Luc Maranget wrote: > > I have two polymorphic variant types, as follows: > > > > type f = [`A | `B of f] > > type g = [f | `C] > > > > Next, I have a function from f to g: > > > > let s1 : f -> g = function > > > > | `A -> `A > > | `B b -> b > > > > Sadly, the compiler rejects this: > > > > Characters 57-58: > > | `B b -> b;; > > that may be too complicated, but it works :-) type 'a f = [`A | `B of 'a];; type 'a g = ['a f | `C];; let s1 (p : 'a f) : 'a g = match p with `A -> `A | `B b -> b;; # s1 (`B (`B `A));; - : 'a g as 'a = `B `A Michael -- C offers you enough rope to hang yourself. C++ offers a fully equipped firing squad, a last cigarette and a blindfold.