From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Delivered-To: caml-list@yquem.inria.fr Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by yquem.inria.fr (Postfix) with ESMTP id 79DBBBC32 for ; Tue, 8 Mar 2005 22:01:19 +0100 (CET) Received: from vapor.isi.edu (vapor.isi.edu [128.9.64.64]) by nez-perce.inria.fr (8.13.0/8.13.0) with ESMTP id j28L1Iv8021182 for ; Tue, 8 Mar 2005 22:01:18 +0100 Received: from albini.isi.edu (albini.isi.edu [128.9.216.111]) by vapor.isi.edu (8.11.6p2+0917/8.11.2) with ESMTP id j28L0tB22228; Tue, 8 Mar 2005 13:00:55 -0800 (PST) Date: Tue, 8 Mar 2005 13:00:55 -0800 (PST) From: Hal Daume III To: Martin Jambon Cc: Andreas Rossberg , Subject: Re: [Caml-list] AST traversal functions (was: SML->OCaml) In-Reply-To: Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-ISI-4-38-10-MailScanner: Found to be clean X-MailScanner-From: hdaume@isi.edu X-Miltered: at nez-perce with ID 422E129E.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Spam: no; 0.00; caml-list:01 ast:01 ocaml:01 explicitely:01 repetitive:01 error-prone:01 higher-order:01 ast:01 pcaml:01 expr:01 val:01 fwiw:01 haskell:01 haskell:01 replacing:01 X-Spam-Checker-Version: SpamAssassin 3.0.2 (2004-11-16) on yquem.inria.fr X-Spam-Status: No, score=0.0 required=5.0 tests=none autolearn=disabled version=3.0.2 X-Spam-Level: > It just requires a good root-to-leaves substitution function which does > not ask us to match explicitely every kind of node of a given type (which > is extremely repetitive and error-prone, even with quotations). I already > thought of doing this (actually automatically deriving such a higher-order > function from the type definition of the AST: Pcaml.expr and friends). > > This would let us focus only on the specific cases such as "open", > "let ... in", "fun ...", "let ..." (or "val ..."), simple identifiers and > module-related issues. FWIW, this is exactly what the "scrap your boilerplate" proposal in Haskell does. I've used it to do something relatively similar: converting multiple Haskell modules into one large module. The brunt of the work is basically in replacing identifiers with something unique, and is more or less the same as the problem you're talking about here. The code for the traversal is about 300 lines, compared to the several thousands of which would be required to match every constructor. -- Hal Daume III | hdaume@isi.edu "Arrest this man, he talks in maths." | www.isi.edu/~hdaume