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 85317BC69 for ; Sun, 4 Mar 2007 13:04:23 +0100 (CET) Received: from nf-out-0910.google.com (nf-out-0910.google.com [64.233.182.187]) by discorde.inria.fr (8.13.6/8.13.6) with ESMTP id l24C4NNo002440 for ; Sun, 4 Mar 2007 13:04:23 +0100 Received: by nf-out-0910.google.com with SMTP id m19so1656725nfc for ; Sun, 04 Mar 2007 04:04:23 -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=gc+njhULPhIY6fsnA0CCP32zKvW/v8vSW4qTevf13+WgIQDDyvNT90ZVPxNDSRO8UfbVDnv0RtCoQzMhfJflC5Hq2QE98TlFSMyNDjxAzYvh2+fTKVatMaibQIONdRCu/5MWTssRxZIimTh0lrIkleNsq0/lVSzuJuMbDj2bykE= 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=OGFuvWnsaUqsAU2FZaoCQ74daXqAn+6R7mJLupJqMlkM02TSxSEnty02PktLQqv7T527kTWN1wADz87Wnm1W969O1usDNo1TYfensMC9s0GYN9XxzNoihYmxI9MT2hInNTngiIEvi8OwypRQC8eV8dYic6hi3K+fcvZagKkSCDc= Received: by 10.82.175.2 with SMTP id x2mr3350707bue.1173009862822; Sun, 04 Mar 2007 04:04:22 -0800 (PST) Received: by 10.82.136.14 with HTTP; Sun, 4 Mar 2007 04:04:22 -0800 (PST) Message-ID: <4a708d20703040404y4973ca00if881bd4ef65f3a1e@mail.gmail.com> Date: Sun, 4 Mar 2007 13:04:22 +0100 From: "Lukasz Stafiniak" To: eliot@generation.net Subject: Re: [Caml-list] records with polymorphic variants? Cc: caml In-Reply-To: <45EA613F.3030104@generation.net> 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> X-j-chkmail-Score: MSGID : 45EAB5C7.000 on discorde : j-chkmail score : X : 0/20 1 0.000 -> 1 X-Miltered: at discorde with ID 45EAB5C7.000 by Joe's j-chkmail (http://j-chkmail . ensmp . fr)! X-Spam: no; 0.00; lukasz:01 variants:01 ocaml:01 ocaml:01 mismatch:01 syntax:01 foo:01 syntax:01 foo:01 unnamed:98 unbound:01 polymorphic:01 polymorphic:01 beginners:01 beginners:01 This question should go to the "OCaml Beginners" . On 3/4/07, Eliot Handelman wrote: > Hi, > > I'm trying to figure out how to define a record with a field whose type > is an extensible polymorphic variant. > > I can this: > > type f = [ `A of int ] > > type r = { x : f } > > but then I can't do this: > > { x = `B "test" } This is crearly a type mismatch: you specified r.x to allow only `A of int. > > I'm not even sure if what I'm asking for is possible. > I don't think so. > Guessing at the syntax I tried > > type r = { > f : [> #foo] > } > > which results in: > > Warning D: this syntax is deprecated. > f : [> #foo] > ^^^^ > Characters 24-28: > f : [> #foo] > ^^^^ > The type [< foo ] is not a polymorphic variant type > Try the syntax: # type r = {x : [> foo]};; Characters 14-21: type r = {x : [> foo]};; ^^^^^^^ Unbound type parameter [..] The open variant type introduces a type parameter, which is not bound in definition of type r. I don't think these unnamed parameters can be bound, so that you could write: "type 'a r = {x : foo SUM 'a}". > I hope it is clear what I'm trying to do. Thanks for your help. > No, it is not clear. You haven't specified the context.