Modular Generic Programming

Generic programming is a style of programming where a single generic function definition (i.e. algorithm) is applicable to a wide range of data types. This is in contrast to a ad-hoc polymorphic function which provides a separate definition for each data type.

There are a number of compelling approaches such as Hinze's ``Generics for the Masses'' (GM) and Lämmels/Peyton Jones' ``Scrap your Boilerplate'' (SYB) which exploit ad-hoc polymorphism to support generic programming. To achieve modularity, however, they require some experimental language extensions such as abstraction over type classes and recursive instances. Hence, the type class encodings behind the GM and SYB approach become less practical and harder to understand. In [3], I showed that none of these type class features are necessary if we use the single feature of extensible superclasses, the complement of subclass extension. Thus, we can write modular, generic programs while maintaining a light-weight type class encoding.



Martin Sulzmann 2006-07-19