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=1.1 required=5.0 tests=AWL,SPF_NEUTRAL autolearn=disabled version=3.1.3 Received: from discorde.inria.fr (discorde.inria.fr [192.93.2.38]) by yquem.inria.fr (Postfix) with ESMTP id 23E8FBC69 for ; Mon, 30 Apr 2007 10:53:18 +0200 (CEST) Received: from ug-out-1314.google.com (ug-out-1314.google.com [66.249.92.168]) by discorde.inria.fr (8.13.6/8.13.6) with ESMTP id l3U8rHeC009933 for ; Mon, 30 Apr 2007 10:53:17 +0200 Received: by ug-out-1314.google.com with SMTP id k3so1004980ugf for ; Mon, 30 Apr 2007 01:53:17 -0700 (PDT) DKIM-Signature: a=rsa-sha1; c=relaxed/relaxed; d=gmail.com; s=beta; h=domainkey-signature:received:received:in-reply-to:references:mime-version:content-type:message-id:cc:content-transfer-encoding:from:subject:date:to:x-mailer; b=JM5OgVjID7YBT9ldUxYOR/TkRXQRE7k8ZSNxSExpiwlLDGiNm72uxcGFKNM+i/xJ8oTHK0bHV6n4rauVuC9sE6NP2q9MAfy2GBXsq3DGycNoA5zPHH85Q3Z1I8iz+E50fuWsZwbijS+t+nPFMQgNDVwmuFKaBdm9Jvf+ECanFSI= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=beta; h=received:in-reply-to:references:mime-version:content-type:message-id:cc:content-transfer-encoding:from:subject:date:to:x-mailer; b=o36OMp5waj1qd2hmmFwrxypHaffu6qiCE9Qba6QoC2LxRoDy34PrzW/V3V5ZkA1MXQV8ArkfkIKLIPoIA/zam+mc5zYRMEVzQObMqinjsalKs3BLi2UVGueRcVWyHAu9CirgBrOaQHzHS2JlKR9npSkx9+npj+kHA1ENyrvHDNg= Received: by 10.67.21.11 with SMTP id y11mr5281761ugi.1177923197555; Mon, 30 Apr 2007 01:53:17 -0700 (PDT) Received: from ?192.168.1.34? ( [81.37.190.201]) by mx.google.com with ESMTP id 27sm6353570ugp.2007.04.30.01.53.16; Mon, 30 Apr 2007 01:53:16 -0700 (PDT) In-Reply-To: References: <0DF43C61-05DE-4129-A5F6-06AF8722A8D5@gmail.com> Mime-Version: 1.0 (Apple Message framework v752.3) Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed Message-Id: Cc: "Caml List" Content-Transfer-Encoding: 7bit From: Joel Reymont Subject: Re: [Caml-list] AST transformation and scrapping boilerplate code Date: Mon, 30 Apr 2007 09:53:14 +0100 To: Nicolas Pouillard X-Mailer: Apple Mail (2.752.3) X-j-chkmail-Score: MSGID : 4635AE7D.000 on discorde : j-chkmail score : XXX : 5/20 1 0.000 -> 3 X-Miltered: at discorde with ID 4635AE7D.000 by Joe's j-chkmail (http://j-chkmail . ensmp . fr)! X-Spam: no; 0.00; variants:01 constructors:01 variants:01 camlp:01 pointers:01 camlp:01 expr:01 expr:01 2007,:98 polymorphic:01 polymorphic:01 wrote:01 constructor:01 caml-list:01 inherit:01 A combination of polymoprhic variants with generated map and fold traversals would be incredibly useful in AST transformations. Imagine the case where some constructors are "shared" between different ASTs, e.g. type ty = [`A a|`B b] in one module and type ty = [`B b|`C c|` d] in another. You need to transform the first type into the second. You could use the example below and add matches for special cases where either the target constructor is different or different actions need to be taken. Is adding polymorphic variants to camlp4 something that can be accomplished by mere mortals? Any pointers on where to start and how to proceed? Thanks, Joel On Apr 30, 2007, at 9:21 AM, Nicolas Pouillard wrote: > However these to generators don't handle polymorphic variants. > [...] > class map = Camlp4Filters.GenerateMap.generated;; > class fold = Camlp4Filters.GenerateFold.generated;; > > let strip_postions = object inherit map as super > method expr e = > match super#expr e with > | TokenPos(a, _) -> a > | e -> e > end -- http://wagerlabs.com/