"Scrap Your Boilerplate" Revolutions
Ralf Hinze and Andres Löh

Generic programming allows you to write a function once, and use it many times at different types. Traditionally, generic functions are defined by induction on the structure of types. "Scrap your boilerplate" (SYB) is a radically different approach that dispatches on the structure of values. In previous work, we have shown how to reconcile both approaches using the concept of generic views: many generic functions can be based either on the classical sum-of-products view or on the view that underlies SYB, the so-called 'spine' view. One distinct advantage of the spine view is its generality: it is applicable to a large class of data types, including generalised algebraic data types. Its main weakness roots in the value-orientation: one can only define generic functions that consume data (show) but not ones that produce data (read). Furthermore, functions that abstract over type constructors (map, reduce) are out of reach. In this paper, we show how to overcome both limitations. The main technical contributions are the 'type spine' view and the 'lifted spine' view.

Download
Paper, accepted at MPC 2006
Haskell source code (executable Haskell file containing all example code, automatically generated from the paper sources)
Links
The original "Scrap Your Boilerplate" site
"Scrap your boilerplate" reloaded" is the predecessor of this paper.

Valid XHTML 1.0! Valid CSS! Get Firefox!

Andres Löh, 20.03.2006