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 concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by yquem.inria.fr (Postfix) with ESMTP id C8BC2BC69 for ; Wed, 25 Apr 2007 07:54:13 +0200 (CEST) Received: from ipmail01.adl2.internode.on.net (ipmail01.adl2.internode.on.net [203.16.214.140]) by concorde.inria.fr (8.13.6/8.13.6) with ESMTP id l3P5sBai016640 for ; Wed, 25 Apr 2007 07:54:12 +0200 X-IronPort-AV: E=Sophos;i="4.14,449,1170595800"; d="scan'208";a="119188459" Received: from ppp8-148.lns1.syd7.internode.on.net (HELO [192.168.1.201]) ([59.167.8.148]) by ipmail01.adl2.internode.on.net with ESMTP; 25 Apr 2007 15:24:08 +0930 Subject: Re: [Caml-list] Transforming of ASTs and polymorphic variants From: skaller To: Joel Reymont Cc: Caml List In-Reply-To: <15893C08-FD0C-456B-A12F-DADCF6CC95F9@gmail.com> References: <15893C08-FD0C-456B-A12F-DADCF6CC95F9@gmail.com> Content-Type: text/plain Date: Wed, 25 Apr 2007 15:54:05 +1000 Message-Id: <1177480445.7544.14.camel@rosella.wigram> Mime-Version: 1.0 X-Mailer: Evolution 2.10.1 Content-Transfer-Encoding: 7bit X-Miltered: at concorde with ID 462EED03.002 by Joe's j-chkmail (http://j-chkmail . ensmp . fr)! X-Spam: no; 0.00; transforming:01 variants:01 0100,:01 constructors:01 sourceforge:01 polymorphic:01 beginners:01 wrote:01 constructor:01 integer:01 integer:01 caml-list:01 boolean:02 boolean:02 modules:02 On Wed, 2007-04-25 at 05:19 +0100, Joel Reymont wrote: > My apologies if this is a beginners question... > > I have two ASTs in different modules that look very much alike in > that some constructors have the same name and type name. When I > transform that ASTs I end up "re-applying" the similarly named > constructor and arguments. This is best explained with an example. a.ml: type typ = [ | `Integer | `Double | `String | `Boolean ] b.ml: type ty = [ | `Integer | `Double | `String | `Boolean | `Void ] A transformation function would be let conv_type (x:A.typ): B.ty = match x with | x -> (x : A.typ :> B.ty) A simpler implementation: let conv_type x = (x : A.typ :> B.ty) will also work in this case. -- John Skaller Felix, successor to C++: http://felix.sf.net