Scrap more boilerplate: reflection, zips, and generalised casts

Authors
Ralf Lämmel and Simon Peyton-Jones

Note
See the Scrap your boilerplate approach website.

Abstract
Writing boilerplate code is a royal pain. Generic programming promises to alleviate this pain by allowing the programmer to write a generic ``recipe'' for boilerplate code, and use that recipe in many places. In earlier work we introduced the ``Scrap your boilerplate'' approach to generic programming, which exploits Haskell's existing type-class mechanism to support generic transformations and queries. This paper completes the picture. We add a few extra ``introspective'' or ``reflective'' facilities, that together support a rich variety of serialisation and de-serialisation. We also show how to perform generic ``zips'', which at first appear to be somewhat tricky in our framework. Lastly, we generalise the ability to over-ride a generic function with a type-specific one. All of this can be supported in Haskell with independently-useful extensions: higher-rank types and type-safe cast. The GHC implementation of Haskell readily derives the required type classes for user-defined data types.

Bibtex entries
@inproceedings{syb2,
 author    = {Ralf L{\"a}mmel and Simon {Peyton Jones}},
 title     = "{Scrap more boilerplate:
               reflection, zips, and generalised casts}",
 booktitle = "{Proceedings of the ACM SIGPLAN International Conference
               on Functional Programming (ICFP 2004)}",
 year      = {2004},
 pages     = {244--255},
 location  = {Snow Bird, UT, USA},
 publisher = {ACM Press},
}

Downloads


maintained by Ralf Lämmel (Email: Ralf.Lammel@microsoft.com)