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 mail1-relais-roc.national.inria.fr (mail1-relais-roc.national.inria.fr [192.134.164.82]) by yquem.inria.fr (Postfix) with ESMTP id A09D1BBAF for ; Wed, 20 Aug 2008 15:25:11 +0200 (CEST) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AscCACW4q0jAXQIniGdsb2JhbACSFwEBAQ8goxSBWQ X-IronPort-AV: E=Sophos;i="4.32,239,1217800800"; d="scan'208";a="16296776" Received: from concorde.inria.fr ([192.93.2.39]) by mail1-smtp-roc.national.inria.fr with ESMTP; 20 Aug 2008 15:25:11 +0200 Received: from mail3-relais-sop.national.inria.fr (mail3-relais-sop.national.inria.fr [192.134.164.104]) by concorde.inria.fr (8.13.6/8.13.6) with ESMTP id m7KDP9xO023765 (version=TLSv1/SSLv3 cipher=RC4-SHA bits=128 verify=OK) for ; Wed, 20 Aug 2008 15:25:11 +0200 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AhcBANC3q0iCcUBThWdsb2JhbACSFwEBAQoFAgYHEaMPgVk X-IronPort-AV: E=Sophos;i="4.32,239,1217800800"; d="scan'208";a="16136463" Received: from sigma957.cis.mcmaster.ca ([130.113.64.83]) by mail3-smtp-sop.national.inria.fr with ESMTP; 20 Aug 2008 15:25:10 +0200 Received: from Dura7.UTS.McMaster.CA (dura7.UTS.mcmaster.ca [130.113.196.62]) by sigma957.cis.mcmaster.ca (8.13.7/8.13.7) with ESMTP id m7KDOVmS024857; Wed, 20 Aug 2008 09:25:07 -0400 (EDT) Received: from cgpsrv2.cis.mcmaster.ca (univmail.CIS.McMaster.CA [130.113.64.46]) by Dura7.UTS.McMaster.CA (8.13.7/8.13.7) with ESMTP id m7KDO23h007674; Wed, 20 Aug 2008 09:24:12 -0400 Received: from [72.138.80.237] (account carette@univmail.cis.mcmaster.ca HELO [192.168.1.101]) by cgpsrv2.cis.mcmaster.ca (CommuniGate Pro SMTP 4.3.12) with ESMTPSA id 221582780; Wed, 20 Aug 2008 09:24:02 -0400 Message-ID: <48AC1AF6.6050701@mcmaster.ca> Date: Wed, 20 Aug 2008 09:24:06 -0400 From: Jacques Carette Organization: McMaster University User-Agent: Thunderbird 2.0.0.16 (Windows/20080708) MIME-Version: 1.0 To: Jacques Garrigue Cc: caml-list@inria.fr Subject: Re: [Caml-list] Not a variant?? References: <48AB4F06.4070208@mcmaster.ca> <20080820.122102.241911903.garrigue@math.nagoya-u.ac.jp> In-Reply-To: <20080820.122102.241911903.garrigue@math.nagoya-u.ac.jp> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-PMX-Version-Mac: 5.4.2.338381, Antispam-Engine: 2.6.0.325393, Antispam-Data: 2008.8.20.131301 X-PerlMx-Spam: Gauge=IIIIIII, Probability=7%, Report='BODY_SIZE_1000_LESS 0, BODY_SIZE_5000_LESS 0, BODY_SIZE_900_999 0, __BOUNCE_CHALLENGE_SUBJ 0, __CT 0, __CTE 0, __CT_TEXT_PLAIN 0, __HAS_MSGID 0, __MIME_TEXT_ONLY 0, __MIME_VERSION 0, __SANE_MSGID 0, __USER_AGENT 0' X-Miltered: at concorde with ID 48AC1B35.000 by Joe's j-chkmail (http://j-chkmail . ensmp . fr)! X-Spam: no; 0.00; wrote:01 complains:01 clearer:01 caml-list:01 constraint:01 constraint:01 variant:02 variant:02 define:02 bounds:02 mcmaster:02 garrigue:03 inheritance:03 workaround:03 jacques:03 Jacques Garrigue wrote: > 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. Indeed - I would suggest that the error include some clearer diagnostics that indicate how the variant is 'inexact'. > The standard workaround is to write: > > type c0 = [a | b] > type 'a c = 'a constraint 'a = [< c0] > This got me further, thanks. But not far enough... Here is a simple example of the problems I am now running into: type 'a a = [`A of 'a ] type 'a b = [`B of 'a ] type d = [`D ] type ('a,'b) e = ['b a | 'a b | d] type ('a,'b) c = ('a,'b) e constraint 'a = [< 'b a ] constraint 'b = [< 'a b ] type 'd cc = 'd constraint 'd = [< ('a,'b) c] let is_cc = function | #cc -> true | _ -> false ;; (* complains that cc is not a variant type when trying to define is_cc *) Jacques Carette