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=0.0 required=5.0 tests=none autolearn=disabled version=3.1.3 Received: from mail2-relais-roc.national.inria.fr (mail2-relais-roc.national.inria.fr [192.134.164.83]) by yquem.inria.fr (Postfix) with ESMTP id A3C7EBB84 for ; Thu, 9 Oct 2008 10:43:38 +0200 (CEST) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AjgEALhg7UhKfU4YgWdsb2JhbACTFz4BARYiA6NPhwYBAoNo X-IronPort-AV: E=Sophos;i="4.33,382,1220220000"; d="scan'208";a="15828873" Received: from ey-out-2122.google.com ([74.125.78.24]) by mail2-smtp-roc.national.inria.fr with ESMTP; 09 Oct 2008 10:43:38 +0200 Received: by ey-out-2122.google.com with SMTP id 6so1357034eyi.15 for ; Thu, 09 Oct 2008 01:43:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from:sender :to:subject:cc:in-reply-to:mime-version:content-type :content-transfer-encoding:content-disposition:references :x-google-sender-auth; bh=3QvQ/li83So8I963ioXBJXd24Utjxj16KFHNzO5tZqQ=; b=jdPPRY9pPyiouYH+PG2QFNLEb7Gtt6DRuP3Rzucj/nb4EhNg090PT5DHXRlVghLrUF Ajk8ny3r5SUp4xtiK9TLkC7YVV0TJxrhSGSafPHH4ySsfRO+Nr0t/hU4+9g/ph2/1mQ+ 6BIrXgYjvBb+RlTtTEzBItHWYPTOPLeAtovrM= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:sender:to:subject:cc:in-reply-to:mime-version :content-type:content-transfer-encoding:content-disposition :references:x-google-sender-auth; b=UIdZ8PQuOlBqOyJK+r6W/oho7LaeAYmCm+yejPfW1Qw7wpaY76EzBXkeXGo3Lv9BfQ /IPiP8JGiBQQLDLdxXGzg5u/hb4Z3DchIZLHbqd+RbgpN9bziyyL+ovJM6WJTkfGe99o 9Lln3sSOiNEg4ksCu08YzQZwI9R9Qsque+g5c= Received: by 10.210.117.1 with SMTP id p1mr11352479ebc.28.1223541817789; Thu, 09 Oct 2008 01:43:37 -0700 (PDT) Received: by 10.210.43.16 with HTTP; Thu, 9 Oct 2008 01:43:37 -0700 (PDT) Message-ID: <95513600810090143y137a17bcib8a4a7a25c06d6ca@mail.gmail.com> Date: Thu, 9 Oct 2008 10:43:37 +0200 From: "Olivier Andrieu" Sender: oandrieu@gmail.com To: "Conglun Yao" Subject: Re: [Caml-list] conjunctive type in polymorphic variants Cc: caml-list@yquem.inria.fr In-Reply-To: MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline References: X-Google-Sender-Auth: aea30af5e9e52441 X-Spam: no; 0.00; andrieu:01 oandrieu:01 conjunctive:01 variants:01 toploop:01 ocaml:01 variants:01 ocaml:01 parser:01 polymorphic:01 polymorphic:01 wrote:01 caml-list:01 constructor:01 nerim:01 Hi, On Thu, Oct 9, 2008 at 06:15, Conglun Yao wrote: > Sorry, I can't fully understand the source code, but it seems we can > only define a polymorphic variant with only one additional type > declaration, like > `A of int or `A of (int * int) > rather than `A of int * int That's correct. > It looks wired, as we can directly define > type t = [ `A of int * int | `B of string ] in toploop or a *.ml file. yes, that's because ocaml handle the "of int * int" a bit differently in regular and polymorphic variant declarations: - in the regular variant the * is a separator between constructor arguments (thus two arguments) - polymorphic variants only have one argument, so int * int is treated as a whole type expression and * is the "tupling" operator So yes, this looks wired in the ocaml parser. -- Olivier