Advertisement

Scrap Your Boilerplate

  • Simon Peyton Jones
  • Ralf Lämmel
Conference paper
Part of the Lecture Notes in Computer Science book series (LNCS, volume 2895)

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.

Copyright information

© Springer-Verlag Berlin Heidelberg 2003

Authors and Affiliations

  • Simon Peyton Jones
    • 1
  • Ralf Lämmel
    • 2
  1. 1.Microsoft ResearchCambridge
  2. 2.Vrije UniversityAmsterdam

Personalised recommendations