Scrap your boilerplate with class: extensible generic functions

  • Authors:
  • Ralf Lämmel;Simon Peyton Jones

  • Affiliations:
  • Microsoft Corp.;Microsoft Research

  • Venue:
  • Proceedings of the tenth ACM SIGPLAN international conference on Functional programming
  • Year:
  • 2005

Quantified Score

Hi-index 0.00

Visualization

Abstract

The 'Scrap your boilerplate' approach to generic programming allows the programmer to write generic functions that can traverse arbitrary data structures, and yet have type-specific cases. However, the original approach required all the type-specific cases to be supplied at once, when the recursive knot of generic function definition is tied. Hence, generic functions were closed. In contrast, Haskell's type classes support open, or extensible, functions that can be extended with new type-specific cases as new data types are defined. In this paper, we extend the 'Scrap your boilerplate' approach to support this open style. On the way, we demonstrate the desirability of abstraction over type classes, and the usefulness of recursive dictionarie.