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 X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr 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 903FFBB84 for ; Thu, 9 Oct 2008 06:15:23 +0200 (CEST) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: Ao8CAKki7UjAXQIniGdsb2JhbACMJoZtPgEBARUiojdthxABAg X-IronPort-AV: E=Sophos;i="4.33,381,1220220000"; d="scan'208";a="15822084" Received: from concorde.inria.fr ([192.93.2.39]) by mail2-smtp-roc.national.inria.fr with ESMTP; 09 Oct 2008 06:15:18 +0200 Received: from mail1-relais-roc.national.inria.fr (mail1-relais-roc.national.inria.fr [192.134.164.82]) by concorde.inria.fr (8.13.6/8.13.6) with ESMTP id m994FImD027099 (version=TLSv1/SSLv3 cipher=RC4-SHA bits=128 verify=OK) for ; Thu, 9 Oct 2008 06:15:18 +0200 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AuIFADAi7UjRVdkVbWdsb2JhbACMJoZtPhcjojlthxABAg X-IronPort-AV: E=Sophos;i="4.33,381,1220220000"; d="scan'208";a="18434293" Received: from mail-gx0-f21.google.com ([209.85.217.21]) by mail1-smtp-roc.national.inria.fr with ESMTP; 09 Oct 2008 06:15:17 +0200 Received: by gxk14 with SMTP id 14so12278298gxk.9 for ; Wed, 08 Oct 2008 21:15:16 -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:mime-version:content-type:content-transfer-encoding :content-disposition; bh=DEx/oyr2DyKIfSu2sieXRVa16YxErwunvE6j+9TK/sA=; b=C8QR4llCxTNLqee+b3oHI7XuNDwQOU2q+eIa9NmBEMWcKm7kNSxDLwu5Dg6jU6Gdtd 4HjU9r1ocHyOPiXqRc1SfPVlgoGgocyZiAE6+OyG9SsvucrRQWbcGGkHRF+ozByx3PWo r10N581sHOHfe2NINp9+YUTDOT7FA9ihzL9nk= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:to:subject:mime-version:content-type :content-transfer-encoding:content-disposition; b=mC5xYUr2+b45N1MlvX57ulPPLITo0PkoKDAZsIW+ex1/A3t8guciE5dxnrdmxO9lTM 6ocIooYQV37lS3PEQB6RIt9C+Gm7INpP70Es8mSzMa87i2J7iQdHyxqchOMY/cpZsmUG f9MRG9Png3g4E1Cv0M336xwoOmdAmIlKHHeJM= Received: by 10.151.9.1 with SMTP id m1mr12234812ybi.199.1223525716726; Wed, 08 Oct 2008 21:15:16 -0700 (PDT) Received: by 10.151.9.13 with HTTP; Wed, 8 Oct 2008 21:15:16 -0700 (PDT) Message-ID: Date: Thu, 9 Oct 2008 05:15:16 +0100 From: "Conglun Yao" To: caml-list@inria.fr Subject: conjunctive type in polymorphic variants MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline X-Miltered: at concorde with ID 48ED8556.000 by Joe's j-chkmail (http://j-chkmail . ensmp . fr)! X-Spam: no; 0.00; conjunctive:01 variants:01 camlp:01 conjunctive:01 compiler:01 ocaml:01 ocaml-:01 typetexp:01 stl:01 stl:01 ptyp:01 toploop:01 polymorphic:01 polymorphic:01 typing:01 Hi all, I have just met a strange problem (it might have already been answered, but I can't find the it) while using camlp4 to generate a polymorphic type like: type t = [ `A of int * int | `B of string ] error msg "The present constructor A has a conjunctive type" is thrown by the compiler. I followed the ocaml source code, found in ocaml-3.10.2/typing/typetexp.ml Line 290, it does the following check in add_field function: if List.length stl > 1 || c && stl <> [] then raise(Error(styp.ptyp_loc, Present_has_conjunction l)); 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 It looks wired, as we can directly define type t = [ `A of int * int | `B of string ] in toploop or a *.ml file. Or I have some mis-understanding in this part. Thanks for any help. Best regards, Conglun