English version
Accueil     À propos     Téléchargement     Ressources     Contactez-nous    

Ce site est rarement mis à jour. Pour les informations les plus récentes, rendez-vous sur le nouveau site OCaml à l'adresse ocaml.org.

Browse thread
RE: [Caml-list] SML->OCaml
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2005-03-08 (21:01)
From: Hal Daume III <hdaume@I...>
Subject: Re: [Caml-list] AST traversal functions (was: SML->OCaml)
> 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