Skip to main content
×
×
Home

A lightweight approach to datatype-generic rewriting

  • THOMAS VAN NOORT (a1), ALEXEY RODRIGUEZ YAKUSHEV (a2), STEFAN HOLDERMANS (a2), JOHAN JEURING (a3), BASTIAAN HEEREN (a4) and JOSÉ PEDRO MAGALHÃES (a5)...
Abstract

Term-rewriting systems can be expressed as generic programs parameterised over the shape of the terms being rewritten. Previous implementations of generic rewriting libraries require users to either adapt the datatypes that are used to describe these terms or to specify rewrite rules as functions. These are fundamental limitations: the former implies a lot of work for the user, while the latter makes it hard if not impossible to document, test, and analyze rewrite rules. In this article, we demonstrate how to overcome these limitations by making essential use of type-indexed datatypes. Our approach is lightweight in that it is entirely expressible in Haskell with GADTs and type families and can be readily packaged for use with contemporary Haskell distributions.

Copyright
References
Hide All
Backhouse, R. C., Jansson, P., Jeuring, J. & Meertens, L. (1999) Generic programming: an introduction. In Advanced Functional Programming, Third International School, Braga, Portugal, September 12–19, 1998, Revised Lectures, Swierstra, S. D., Henriques, P. R. & Oliveira, J. N. (eds), Lecture Notes in Computer Science, vol. 1608. Springer-Verlag, pp. 28115.
Borovanský, P., Kirchner, C., Kirchner, H. & Ringeissen, C. (2001) Rewriting with strategies in ELAN: a functional semantics, Int. J. Found. Comput. Sci., 12 (1), 6995.
Bravenboer, M., Kalleberg, K. T. & Visser, E. (2008) Stratego/XT 0.17: a language and toolset for program transformation. Sci. Comput. Program., 72 (1–2), 5270.
Bringert, B. & Ranta, A. (2006) A pattern for almost compositional functions. In Proceedings of the 11th ACM SIGPLAN International Conference on Functional Programming, ICFP 2006, Portland, Oregon, USA, September 16–21, 2006, Reppy, J. H. & Lawall, J. L. (eds), ACM Press, pp. 216226.
Brown, N. C. C. & Sampson, A. T. (2008) Matching and modifying with generics. In Draft Proceedings of the Ninth Symposium on Trends in Functional Programming (TFP), May 26–28, 2008, Center Parcs “Het Heijderbos”, The Netherlands, Achten, P., Koopman, P. & Morazán, M. T. (eds), The draft proceedings of the symposium have been published as a technical report (ICIS-R08007) at Radboud University Nijmegen, pp. 304318.
Bruijn, N. G. de. (1972) Lambda calculus notation with nameless dummies: a tool for automatic formula manipulation, with application to the Church-rosser theorem, Indagaciones Mathematische, 34, 381392.
Chakravarty, M. M. T., Keller, G. & Peyton Jones, S. (2005a) Associated type synonyms. In Proceedings of the 10th ACM SIGPLAN International Conference on Functional Programming, ICFP 2005, Tallinn, Estonia, September 26–28, 2005, In Danvy, O. & Pierce, B. C. (eds), ACM Press, pp. 241253.
Chakravarty, M. M. T., Keller, G., Peyton Jones, S. & Marlow, S. (2005b) Associated types with class. In Proceedings of the 32nd ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages, POPL 2005, Long Beach, California, USA, January 12–14, 2005, Palsberg, J. & Abadi, M. (eds), ACM Press, pp. 113.
Claessen, K. & Hughes, J. (2000) QuickCheck: a lightweight tool for random testing of Haskell programs. In Proceedings of the Fifth ACM SIGPLAN International Conference on Functional Programming (ICFP '00), Montreal, Canada, September 18–21, 2000. ACM Press, pp. 268279.
Deursen, A. van, Heering, J. & Klint, P. (eds). (1996) Language Prototyping. an Algebraic Specification Approach. AMAST Series in Computing, vol. 5. Singapore: World Scientific.
Goguen, J. & Grant, M. (1997) Algebraic Semantics of Imperative Programs. Cambridge, Massachusetts: The MIT Press.
Heeren, B., Jeuring, J., Leeuwen, A. van & Gerdes, A. (2008) Specifying strategies for exercises. In Intelligent Computer Mathematics, 9th International Conference, AISC 2008, 15th Symposium, Calculemus 2008, 7th International Conference, MKM 2008, Birmingham, UK, July 28–August 1, 2008, Proceedings, Autexier, S., Campbell, J., Rubio, J., Sorge, V., Suzuki, M. & Wiedijk, F. (eds), Lecture Notes in Computer Science, vol. 5144. Springer-Verlag, pp. 430445.
Hinze, R. (2000) Generic Programs and Proofs. Habilitationsschrift: University of Bonn.
Hinze, R., Jeuring, J. & Löh, A. (2004) Type-indexed data types, Sci. Comput. Program., 51 (2), 117151.
Holdermans, S., Jeuring, J., Löh, A. & Rodriguez Yakushev, A. (2006) Generic views on data types. In Mathemathics of Program Construction, 8th International Conference, MPC 2006, Kuressaare, Estonia, July 3–5, 2006, Proceedings, Uustalu, T. (ed), Lecture Notes in Computer Science, vol. 4014. Springer-Verlag, pp. 209234.
Jansson, P. & Jeuring, J. (1997) PolyP: a polytypic programming language. In Conference Record of POPL'97: The 24 ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages, Papers Presented at the Symposium, Paris, France, 15–17 January 1997. ACM Press, pp. 68114.
Jansson, P. & Jeuring, J. (1998) Polytypic unification, J. Funct. Program., 8 (5), 527536.
Jansson, P. & Jeuring, J. (2000) A framework for polytypic programming on terms, with an application to rewriting. In Proceedings Workshop on Generic Programming (WGP 2000), July 6, 2000, Ponte de Lima, Portugal, Jeuring, J. (ed), The proceedings of the workshop have been published as a technical report (UU-CS-2000-19) at Utrecht University, pp. 3345.
Lämmel, R. & Peyton Jones, S. (2003) Scrap your boilerplate: a practical design pattern for generic programming. In Proceedings of the ACM SIGPLAN Workshop on Types in Language Design and Implementation (TLDI 2003), New Orleans, LA, USA, January 18, 2003. ACM Press, pp. 2637.
Lämmel, R. & Visser, J. (2002) Typed combinators for generic traversal. In Practical Aspects of Declarative Languages, 4th International Symposium, PADL 2002, Portland, OR, USA, January 19–20, 2002, Krishnamurthi, S. & Ramakrishnan, C. R. (eds), Lecture Notes in Computer Science, vol. 2257. Springer-Verlag, pp. 137154.
Magalhães, J. P., Holdermans, S., Jeuring, J. & Löh, A. (2010) Optimizing generics is easy! In Proceedings of the 2010 ACM SIGPLAN Workshop on Partial Evaluation and Program Manipulation, PEPM 2010, Madrid, Spain, January 18–19, 2010, Gallagher, J. P. & Voigtländer, J. (eds), ACM Press, pp. 3342.
Mitchell, N. & Runciman, C. (2007) Uniform boilerplate and list processing. In Proceedings of the ACM SIGPLAN Workshop on Haskell, Haskell 2007, Freiburg, Germany, September 30, 2007, Keller, G. (ed), ACM Press, pp. 4960.
Noort, T. van, Rodriguez Yakushev, A., Holdermans, S., Jeuring, J. & Heeren, B. (2008) A lightweight approach to datatype-generic rewriting. In Proceedings of the ACM SIGPLAN Workshop on Generic Programming, WGP 2008, Victoria, BC, Canada, September 20, 2008, Hinze, R. & Syme, D. (eds), ACM Press, pp. 1324.
Pasalić, E. & Linger, N. (2004) Meta-programming with typed object-language representations. In Generative Programming and Component Engineering: Third International Conference, GPCE 2004, Vancouver, Canada, October 24–28, 2004, Proceedings, Karsai, G. & Visser, E. (eds), Lecture Notes in Computer Science, vol. 3286. Springer-Verlag, pp. 136167.
Peyton Jones, S., Vytiniotis, D., Weirich, S. & Washburn, G. (2006) Simple unification-based type inference for GADTs. In Proceedings of the 11th ACM SIGPLAN International Conference on Functional Programming, ICFP 2006, Portland, Oregon, USA, September 16–21, 2006, Reppy, J. H. & Lawall, J. L. (eds), ACM Press, pp. 5061.
Schrijvers, T., Peyton Jones, S., Sulzmann, M. & Vytiniotis, D. (2008) Type checking with open type functions. In Proceedings of the 13th ACM SIGPLAN International Conference on Functional Programming, ICFP 2008, Victoria, BC, Canada, September 22–24, 2008, Hook, J. & Thiemann, P. (eds), ACM Press, pp. 5162.
Sheard, T. (2001). Generic unification via two-level types and parameterized modules. In Proceedings of the Sixth ACM SIGPLAN International Conference on Functional Programming (ICFP '01), Florence, Italy, September 3–5, 2001. ACM Press, pp. 8697.
Sheard, T. & Peyton Jones, S. (2002) Template meta-programming for Haskell. In Proceedings of the ACM SIGPLAN Workshop on Haskell, Pittsburgh, Pennsylvania, 2002. ACM Press, pp. 116.
Xi, H., Chen, C. & Chen, G. (2003) Guarded recursive datatype constructors. In Conference Record of POPL 2003: The 30th SIGPLAN-SIGACT Symposium on Principles of Programming Languages, New Orleans, Louisiana, January 15–17, 2003. ACM Press, pp. 224235.
Recommend this journal

Email your librarian or administrator to recommend adding this journal to your organisation's collection.

Journal of Functional Programming
  • ISSN: 0956-7968
  • EISSN: 1469-7653
  • URL: /core/journals/journal-of-functional-programming
Please enter your name
Please enter a valid email address
Who would you like to send this to? *
×

Metrics

Full text views

Total number of HTML views: 0
Total number of PDF views: 0 *
Loading metrics...

Abstract views

Total abstract views: 0 *
Loading metrics...

* Views captured on Cambridge Core between <date>. This data will be updated every 24 hours.

Usage data cannot currently be displayed

A lightweight approach to datatype-generic rewriting

  • THOMAS VAN NOORT (a1), ALEXEY RODRIGUEZ YAKUSHEV (a2), STEFAN HOLDERMANS (a2), JOHAN JEURING (a3), BASTIAAN HEEREN (a4) and JOSÉ PEDRO MAGALHÃES (a5)...
Submit a response

Discussions

No Discussions have been published for this article.

×

Reply to: Submit a response


Your details


Conflicting interests

Do you have any conflicting interests? *