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 discorde.inria.fr (discorde.inria.fr [192.93.2.38]) by yquem.inria.fr (Postfix) with ESMTP id 871C1BC69 for ; Sun, 4 Mar 2007 17:24:44 +0100 (CET) Received: from nf-out-0910.google.com (nf-out-0910.google.com [64.233.182.184]) by discorde.inria.fr (8.13.6/8.13.6) with ESMTP id l24GOi7R014660 for ; Sun, 4 Mar 2007 17:24:44 +0100 Received: by nf-out-0910.google.com with SMTP id m19so1697775nfc for ; Sun, 04 Mar 2007 08:24:43 -0800 (PST) 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=cUcKX3QRCJI7tBih/dYpKrY5ynXnd/OOMYcn/F162Z7fPhIhHHlIpoHyMnLo2J3janyZ/dtGKkUtuZJu601rE3iEmb6giZCpCNeyaQsFUUrx42ATuNu8/sjH2jy/XUQ5YCSVvBeE16roq2mofg65dbz9o+Mg6JChOKQ3ZHp0Xkw= 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=kv+U8aZaw0mvOmMcPtM0bRK+XnFJmqnuXwl2GVhliPOaExQ1B9qsT2mVnXagzyCc5TXw6Fr6u7DbQRENNqfMs5YNbN5VPKlNtaHT2AYTDlHDhrDRjDhYHIbinNRMpjjoHM8U9nnYpeoN+wG0+1imjNFF54NPad343J9sdOgAmio= Received: by 10.82.135.13 with SMTP id i13mr3807954bud.1173025483543; Sun, 04 Mar 2007 08:24:43 -0800 (PST) Received: by 10.82.136.14 with HTTP; Sun, 4 Mar 2007 08:24:43 -0800 (PST) Message-ID: <4a708d20703040824o20b1d572h786d46da586c9977@mail.gmail.com> Date: Sun, 4 Mar 2007 17:24:43 +0100 From: "Lukasz Stafiniak" To: "Zheng Li" Subject: Re: [Caml-list] Re: records with polymorphic variants? Cc: caml-list@inria.fr In-Reply-To: <87k5xxjdgv.fsf@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline References: <45EA613F.3030104@generation.net> <87k5xxjdgv.fsf@gmail.com> X-j-chkmail-Score: MSGID : 45EAF2CC.000 on discorde : j-chkmail score : X : 0/20 1 0.000 -> 1 X-Miltered: at discorde with ID 45EAF2CC.000 by Joe's j-chkmail (http://j-chkmail . ensmp . fr)! X-Spam: no; 0.00; lukasz:01 variants:01 polymorphism:01 polymorphic:01 polymorphic:01 wrote:01 caml-list:01 writes:01 pps:01 jussieu:01 constraint:01 constraint:01 int:01 int:01 expression:02 On 3/4/07, Zheng Li wrote: > > Hi, > > Eliot Handelman writes: > > type f = [ `A of int ] > > > > type r = { x : f } > > > > but then I can't do this: > > > > { x = `B "test" } > Here you want type f polymorphic, however as the type of a record field, its > polymorphism has to be reflected (bound) as type parameter in the declaration > of r. Yes, but the type f itself is not polymorphic, it is not [> f]. > > I guess you want the follows > > # type 'a r = { x : 'a } constraint 'a = [> f] > type 'a r = { x : 'a; } constraint 'a = [> f ] > # {x = "test"} > Characters 6-12: > { x = "test"};; > ^^^^^^ > This expression has type string but is here used with type [> f ] > # {x = `B "test"} > - : [> `A of int | `B of string ] r = {x = `B "test"} > Nice! I didn't realize this is possible. Thanks.