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.1 required=5.0 tests=AWL 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 E802CBCF3 for ; Thu, 21 Aug 2008 09:49:50 +0200 (CEST) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AgADAEyVrEiCNhABiGdsb2JhbACSGQEBAQ8gonCBWQ X-IronPort-AV: E=Sophos;i="4.32,243,1217800800"; d="scan'208";a="14148931" Received: from concorde.inria.fr ([192.93.2.39]) by mail2-smtp-roc.national.inria.fr with ESMTP; 21 Aug 2008 07:10:50 +0200 Received: from mail2-relais-roc.national.inria.fr (mail2-relais-roc.national.inria.fr [192.134.164.83]) by concorde.inria.fr (8.13.6/8.13.6) with ESMTP id m7L5AkEc022376 for ; Thu, 21 Aug 2008 07:10:50 +0200 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AgADAEyVrEiCNhABiGdsb2JhbACSGQEBAQ8gonCBWQ X-IronPort-AV: E=Sophos;i="4.32,243,1217800800"; d="scan'208";a="14148929" Received: from kurims.kurims.kyoto-u.ac.jp ([130.54.16.1]) by mail2-smtp-roc.national.inria.fr with ESMTP; 21 Aug 2008 07:10:48 +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 m7L5AjMU023551; Thu, 21 Aug 2008 14:10:45 +0900 (JST) Date: Thu, 21 Aug 2008 14:10:26 +0900 (JST) Message-Id: <20080821.141026.119280602.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: <48AC1AF6.6050701@mcmaster.ca> References: <48AB4F06.4070208@mcmaster.ca> <20080820.122102.241911903.garrigue@math.nagoya-u.ac.jp> <48AC1AF6.6050701@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 48ACF8D6.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 garrigue:03 inheritance:03 workaround:03 From: Jacques Carette > 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 *) Sure, you must use #c as pattern, not #cc. Or are you thinking of another problem? Jacques Garrigue