From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by yquem.inria.fr (Postfix) with ESMTP id 7D45CBCAE for ; Thu, 14 Jul 2005 08:45:13 +0200 (CEST) Received: from pauillac.inria.fr (pauillac.inria.fr [128.93.11.35]) by nez-perce.inria.fr (8.13.0/8.13.0) with ESMTP id j6E6jCeX027400 for ; Thu, 14 Jul 2005 08:45:13 +0200 Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id IAA29613 for ; Thu, 14 Jul 2005 08:45:12 +0200 (MET DST) Received: from kurims.kurims.kyoto-u.ac.jp (kurims.kurims.kyoto-u.ac.jp [130.54.16.1]) by concorde.inria.fr (8.13.0/8.13.0) with ESMTP id j6E6jACA003358 for ; Thu, 14 Jul 2005 08:45:11 +0200 Received: from localhost (suiren [130.54.16.25]) by kurims.kurims.kyoto-u.ac.jp (8.13.1/8.13.1) with ESMTP id j6E6j8Yq014666; Thu, 14 Jul 2005 15:45:08 +0900 (JST) Date: Thu, 14 Jul 2005 15:42:58 +0900 (JST) Message-Id: <20050714.154258.68319238.garrigue@math.nagoya-u.ac.jp> To: keiko@kurims.kyoto-u.ac.jp Cc: caml-list@inria.fr Subject: Re: [Caml-list] type parameter of polymorphic variant types From: Jacques Garrigue In-Reply-To: <20050714.130308.68552987.keiko@kurims.kyoto-u.ac.jp> References: <20050714.130308.68552987.keiko@kurims.kyoto-u.ac.jp> X-Mailer: Mew version 4.2 on Emacs 21.3 / Mule 5.0 (SAKAKI) Mime-Version: 1.0 Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Miltered: at nez-perce with ID 42D609F8.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Miltered: at concorde with ID 42D609F6.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Spam: no; 0.00; caml-list:01 checker:01 checker:01 surprising:01 ...:98 ...:98 polymorphic:01 polymorphic:01 defining:01 expression:01 expression:01 jacques:01 jacques:01 constraint:01 constraint:01 X-Spam-Checker-Version: SpamAssassin 3.0.2 (2004-11-16) on yquem.inria.fr X-Spam-Status: No, score=0.0 required=5.0 tests=none autolearn=disabled version=3.0.2 X-Spam-Level: From: Keiko Nakata > Why I cannot have these type definitions? > > #type ('a,'b) t = ['a | 'b] constraint 'a =[>] constraint 'b = [>];; > #type ('a,'b) t = A of 'a * 'b constraint 'a = [>'b];; See the manual, section 6.4, variant types: In all three cases, tags may be either specified directly in the `tag-name [...] form, or indirectly through a type expression. In this last case, the type expression must expand to an exact variant type, whose tag specifications are inserted in its place. The important point here is that type expressions must expand to _exact_ variant types, which are defined as fully specified variant types that cannot be refined anymore. This certainly does not include type variables. > Moreover, for the type definition > > #type ('a, 'b) u = 'a constraint 'a = [>`A | 'b] ;; > > the type checker reports an error > > Characters 48-50: > type ('a,'b) t = A of 'a * 'b constraint 'a = [>'b];; > ^^ > The type 'a is not a polymorphic variant type > > Is this a kind of typo of 'a for 'b or an intention? There seems to be a typo in your report: you say that you are defining a type u, and the type checker reports a problem about a type t. There are known problems with type variable names, but not with type names. If I try your code, I get # type ('a, 'b) u = 'a constraint 'a = [>`A | 'b] ;; ^^ The type 'a is not a polymorphic variant type The variable name does not match. This is not surprising, as the type checker does not remember variable names when they are converted to an internal form. This will have to be fixed someday... Jacques Garrigue