Abstract
Many programs traverse data structures built from rich mutually-recursive data types. Such programs often have a great deal of “boilerplate” code that simply walks the structure, hiding a small amount of “real” code that constitutes the reason for the traversal. ”Generic programming” is the umbrella term to describe a wide variety of programming technology directed at this problem. All these techniques aim to provide mechanical support for the “boilerplate” part, leaving the programmer free to concentrate on the important part of the algorithm. Such generic programs are much more robust to data structure evolution because they contain many fewer lines of type-specific code.
The trouble is that most generic programming techniques either require significant support from the programming language itself, or are inconvenient for the programmer. In this talk I will describe a new approach to generic programming based on the functional language Haskell, which combines programming convenience with very modest demands on the language. Our approach is simple to understand, elegant, reasonably efficient, and handles all the data types found in conventional functional programming languages. It makes essential use of rank-2 polymorphism, an extension found in some implementations of Haskell.
The talk is a development of work first reported in “Scrap your boilerplate”, Laemmel & Peyton Jones, Proc ACM SIGPLAN Workshop on Types in Language Design and Implementation (TLDI 2003), New Orleans, Jan 2003.
Access this chapter
Tax calculation will be finalised at checkout
Purchases are for personal use only
Author information
Authors and Affiliations
Editor information
Editors and Affiliations
Rights and permissions
Copyright information
© 2003 Springer-Verlag Berlin Heidelberg
About this paper
Cite this paper
Jones, S.P., Lämmel, R. (2003). Scrap Your Boilerplate. In: Ohori, A. (eds) Programming Languages and Systems. APLAS 2003. Lecture Notes in Computer Science, vol 2895. Springer, Berlin, Heidelberg. https://doi.org/10.1007/978-3-540-40018-9_23
Download citation
DOI: https://doi.org/10.1007/978-3-540-40018-9_23
Publisher Name: Springer, Berlin, Heidelberg
Print ISBN: 978-3-540-20536-4
Online ISBN: 978-3-540-40018-9
eBook Packages: Springer Book Archive