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 7020BBBB7 for ; Thu, 9 Oct 2008 12:09:18 +0200 (CEST) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AjgEALB07UhKfSwcgWdsb2JhbACTFz4BARYiA6JhbYZ/AQI X-IronPort-AV: E=Sophos;i="4.33,382,1220220000"; d="scan'208";a="15832782" Received: from yx-out-2324.google.com ([74.125.44.28]) by mail2-smtp-roc.national.inria.fr with ESMTP; 09 Oct 2008 12:09:17 +0200 Received: by yx-out-2324.google.com with SMTP id 3so769485yxj.3 for ; Thu, 09 Oct 2008 03:09:17 -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:to :subject:in-reply-to:mime-version:content-type :content-transfer-encoding:content-disposition:references; bh=ldETfY+8uV6CmjxYen44zNGzT/70olGNM7h9dA2bX+c=; b=eRTPgx1ggeWqbFJbYQjVMv6gnCgQ+87d1cvEEXz4lMcHLa4vykvKSoRA0FlkV9Hv4U cjkiWovxyIPMRelXncNNYtDeSR8AODP+0WOvAx69TuNxP21yEi7mJB99w7PZ+tOVGYAD m1hzq9iPzcIXxMJZdTL+fzffprSAN2qiPuQzo= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:to:subject:in-reply-to:mime-version :content-type:content-transfer-encoding:content-disposition :references; b=QW1kyJ17I1FugZJq9VTa+FNZf6tF23IbPndJBNZ8Btx6UM9zVVyYKKkqPzGJ/VNN91 xnZZCg8RcCzjfrfd+nDWLCClEh+scLiHwFEO7lq7CrQr3IjWmeFC4LFl+sdRC15TbC/t WQL18MMwu+XM7c/DY4IVZjWVQv+YJOLLoodxQ= Received: by 10.150.153.3 with SMTP id a3mr2701ybe.114.1223546957178; Thu, 09 Oct 2008 03:09:17 -0700 (PDT) Received: by 10.151.9.13 with HTTP; Thu, 9 Oct 2008 03:09:17 -0700 (PDT) Message-ID: Date: Thu, 9 Oct 2008 11:09:17 +0100 From: "Conglun Yao" To: caml-list@yquem.inria.fr Subject: Re: [Caml-list] conjunctive type in polymorphic variants In-Reply-To: <95513600810090143y137a17bcib8a4a7a25c06d6ca@mail.gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline References: <95513600810090143y137a17bcib8a4a7a25c06d6ca@mail.gmail.com> X-Spam: no; 0.00; conjunctive:01 variants:01 andrieu:01 oandrieu:01 toploop:01 ocaml:01 variants:01 ocaml:01 parser:01 polymorphic:01 polymorphic:01 wrote:01 wrote:01 caml-list:01 constructor:01 Nicolas and Olivier, Thanks for your quick reply, it makes sense! Conglun On Thu, Oct 9, 2008 at 9:43 AM, Olivier Andrieu wrote: > 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 >