A lightweight approach to datatype-generic rewriting
Authors:
Open Access
- 20 September 2008
- conference paper
- Published by Association for Computing Machinery (ACM)
- Vol. 20, 13-24
Abstract
Previous implementations of generic rewriting libraries have a number of limitations: they require the user to either adapt the datatype on which rewriting is applied, or the rewriting rules are specified as functions, which makes it hard or impossible to docu- ment, test, and analyse them. We describe a library that demon- strates how to overcome these limitations by defining rules in terms of datatypes, and show how to use a type-indexed datatype to automatically extend a datatype for syntax trees with a case for metavariables. We then show how rewrite rules can be imple- mented without any knowledge of how the datatype is extended with metavariables. We use Haskell, extended with associated type synonyms, to implement both type-indexed datatypes and generic functions. We analyse the performance of our library and compare it with other approaches to generic rewriting.Keywords
This publication has 19 references indexed in Scilit:
- Specifying Strategies for ExercisesLecture Notes in Computer Science, 2008
- Stream fusion2007
- Generic Views on Data TypesLecture Notes in Computer Science, 2006
- Improved Fusion for Optimizing GenericsLecture Notes in Computer Science, 2005
- Type-indexed data typesScience of Computer Programming, 2004
- Template meta-programming for Haskell2002
- Typed Combinators for Generic TraversalLecture Notes in Computer Science, 2001
- REWRITING WITH STRATEGIES IN $\mathsf{ELAN}$: A FUNCTIONAL SEMANTICSInternational Journal of Foundations of Computer Science, 2001
- Polytypic unificationJournal of Functional Programming, 1998
- The ZipperJournal of Functional Programming, 1997