Generics as a Library
Bruno C.d.S. Oliveira, Ralf Hinze and Andres Löh

A generic function is a function that is defined on the structure of data types: with a single definition, we obtain a function that works for many data types. In contrast, an ad-hoc polymorphic function requires a separate implementation for each data type. Previous work by Hinze on lightweight generic programming has introduced techniques that allow the definition of generic functions directly in Haskell. A severe drawback of these approaches is that generic functions, once defined, cannot be extended with ad-hoc behaviour for new data types, precluding the design of a customizable generic programming library based on these techniques. In this paper, we present a revised version of Hinzes Generics for the masses approach that overcomes this limitation. Using our new technique, writing a customizable generic programming library in Haskell 98 is possible.

Paper presented at TFP 2006
Example code

Valid XHTML 1.0! Valid CSS!

Andres Löh, 2006-05-08