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.4 required=5.0 tests=AWL,DNS_FROM_RFC_ABUSE autolearn=disabled version=3.1.3 Received: from mail1-relais-roc.national.inria.fr (mail1-relais-roc.national.inria.fr [192.134.164.82]) by yquem.inria.fr (Postfix) with ESMTP id 389CDBBAF for ; Wed, 20 Aug 2008 05:21:27 +0200 (CEST) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AsIDAD8qq0iCNhABiGdsb2JhbACSFAEBAQ8go0CBWw X-IronPort-AV: E=Sophos;i="4.32,238,1217800800"; d="scan'208";a="16275209" Received: from concorde.inria.fr ([192.93.2.39]) by mail1-smtp-roc.national.inria.fr with ESMTP; 20 Aug 2008 05:21:27 +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 m7K3LQN5032654 (version=TLSv1/SSLv3 cipher=RC4-SHA bits=128 verify=OK) for ; Wed, 20 Aug 2008 05:21:27 +0200 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AsIDAD8qq0iCNhABiGdsb2JhbACSFAEBAQ8go0CBWw X-IronPort-AV: E=Sophos;i="4.32,238,1217800800"; d="scan'208";a="16275208" Received: from kurims.kurims.kyoto-u.ac.jp ([130.54.16.1]) by mail1-smtp-roc.national.inria.fr with ESMTP; 20 Aug 2008 05:21:25 +0200 Received: from localhost (orion [130.54.16.5]) by kurims.kurims.kyoto-u.ac.jp (8.13.8/8.13.8) with ESMTP id m7K3LLwU010203; Wed, 20 Aug 2008 12:21:21 +0900 (JST) Date: Wed, 20 Aug 2008 12:21:02 +0900 (JST) Message-Id: <20080820.122102.241911903.garrigue@math.nagoya-u.ac.jp> To: carette@mcmaster.ca Cc: caml-list@inria.fr Subject: Re: [Caml-list] Not a variant?? From: Jacques Garrigue In-Reply-To: <48AB4F06.4070208@mcmaster.ca> References: <48AB4F06.4070208@mcmaster.ca> X-Mailer: Mew version 4.2 on Emacs 22.2 / Mule 5.0 (SAKAKI) Mime-Version: 1.0 Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Miltered: at concorde with ID 48AB8DB6.000 by Joe's j-chkmail (http://j-chkmail . ensmp . fr)! X-Spam: no; 0.00; o'caml's:01 bug:01 compile:01 caml-list:01 constraint:01 constraint:01 variant:02 variant:02 bounds:02 mcmaster:02 confusing:02 output:02 garrigue:03 garrigue:03 inheritance:03 From: Jacques Carette > The function f1 below works fine -- so type d is seen to be a variant type. > However, f2 does not compile because type c is *not* a variant type. > > However, if one looks at O'Caml's output for type c, it visually looks > like a variant, while that of d does not. This is highly confusing. > > This looks like a bug to me -- both c and d should be recognized as > variant types. > > Jacques > > type a = [`A ] > type b = [`B ] > type 'a c = 'a > constraint 'a = [< a | b] > ;; The message is maybe not clear enough: for pattern-matching and inheritance, you need an "exact" variant type, i.e. a type whose lower and upper bounds are identical. This is clearly not the case for c. The standard workaround is to write: type c0 = [a | b] type 'a c = 'a constraint 'a = [< c0] Jacques Garrigue