From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail3-relais-sop.national.inria.fr (mail3-relais-sop.national.inria.fr [192.134.164.104]) by yquem.inria.fr (Postfix) with ESMTP id 3949ABBAF for ; Wed, 6 Jan 2010 08:47:41 +0100 (CET) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AtUCAIfOQ0uFBoIFgWdsb2JhbACbXQEBFiSrZYtVAQWEMIMD X-IronPort-AV: E=Sophos;i="4.49,228,1262559600"; d="scan'208";a="41091945" Received: from rabbit.math.nagoya-u.ac.jp (HELO mailhost.math.nagoya-u.ac.jp) ([133.6.130.5]) by mail3-smtp-sop.national.inria.fr with ESMTP; 06 Jan 2010 08:47:39 +0100 Received: from mailhost.math.nagoya-u.ac.jp (localhost [127.0.0.1]) by mailhost.math.nagoya-u.ac.jp (Postfix) with ESMTP id 347C5B636; Wed, 6 Jan 2010 16:47:37 +0900 (JST) Received: from mailhost.math.nagoya-u.ac.jp (camel-172 [172.16.254.4]) by mailhost.math.nagoya-u.ac.jp (Postfix) with ESMTP id E8EEC88A2; Wed, 6 Jan 2010 16:47:36 +0900 (JST) DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=math.nagoya-u.ac.jp; h= date:message-id:to:cc:subject:from:in-reply-to:references :mime-version:content-type:content-transfer-encoding; s=alpha; bh=Zww5tVFCOT29t+QR5XuHakvtAhQ=; b=cnj5iPMpjIXYUcbHqGQg12vJrq58 8PFMbxUmuKIL9kuAV0xbc171e/iXq0dXR9XonFdnkBrhE6Y/kIRwMtq4R4+pDEEj Xc36ocL9fTTUCc+HRAWKH3f4FpCWTCnSy6gXilE2ZMqfXlk5wwkceRXhTfhCZOUx 8ZXbGAahIUlz7Ms= DomainKey-Signature: a=rsa-sha1; h=Received:Date:Message-Id:To:Cc:Subject:From:In-Reply-To:References:X-Mailer:Mime-Version:Content-Type:Content-Transfer-Encoding; b=CIbmmWR/UILGXwYe0GGV2lLoLxAVCStCgQ1eas5iKG8FfpO+YiSF1eDJ9wyXVe7a9ewFyrfVMKnqrG4IghM/GtjQ4oaCqtfGvp5EbgzGFPcjsAVzPlEU2hqkw85U2k+lPVvrIHickEGUTTewXkkwf5vcCXI0GzYO4K8/hUfZkaM=; c=nofws; d=math.nagoya-u.ac.jp; q=dns; s=alpha Received: from localhost (bsdserver02 [172.16.249.2]) by mailhost.math.nagoya-u.ac.jp (Postfix) with ESMTP id C6AD3889F; Wed, 6 Jan 2010 16:47:36 +0900 (JST) Date: Wed, 06 Jan 2010 16:47:36 +0900 (JST) Message-Id: <20100106.164736.44969841.garrigue@math.nagoya-u.ac.jp> To: thelema314@gmail.com Cc: caml-list@yquem.inria.fr Subject: Re: [Caml-list] Error: In the definition of t, type ('a, 'b) t should be ('b, 'a) t From: Jacques Garrigue In-Reply-To: <4B443038.5020204@gmail.com> References: <4B443038.5020204@gmail.com> X-Mailer: Mew version 6.2.51 on Emacs 22.3 / Mule 5.0 (SAKAKI) Mime-Version: 1.0 Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Spam: no; 0.00; recursive:01 variants:01 edgar:98 polymorphic:01 caml-list:01 define:02 argument:02 variables:02 confusing:02 objects:02 garrigue:03 garrigue:03 jacques:03 jacques:03 parameters:03 From: Edgar Friendly > This error message was new to me, and I wondered what's going on and > why: > > # type ('a, 'b) t = [ `A | `T of ('b, 'a) t ];; > Error: In the definition of t, type ('a, 'b) t should be ('b, 'a) t Structural recursive types (objects and polymorphic variants) must be regular. I.e., type abbreviations must always have the same parameters. The error message is a bit confusing, due to the way type variables are printed (original names are not kept), but it says that type parameters got exchanged. If you really want to define this type, you have to unroll it by hand: type ('a, 'b) t = [ `A of 'a | `T of [ `A of 'b | `T of ('a,'b) t]];; (I added an argument to `A to make the parameters meaningful.) Jacques Garrigue