Generic Generic Programming
José Pedro Magalhães, Andres Löh

Generic programming (GP) is a form of abstraction in programming languages that serves to reduce code duplication by exploiting the regular structure of algebraic datatypes. Over the years, several different approaches to GP in Haskell have surfaced. These approaches are often similar, but certain differences make them particularly well-suited for one specific domain or application. As such, there is a lot of code duplication across GP libraries, which is rather unfortunate, given the original goals of GP.

To address this problem, we define conversions from one popular GP library representation to several others. Our work unifies many approaches to GP, and simplifies the life of both library writers and users. Library writers can define their approach as a conversion from our library, obviating the need for writing metaprogramming code for generation of conversions to and from the generic representation. Users of GP, who often struggle to find “the right approach” to use, can now mix and match functionality from different libraries with ease, and need not worry about having multiple (potentially inefficient and large) code blocks for generic representations in different approaches.

Paper, presented at PADL 2014
First draft, submitted to / rejected from ICFP 2013
Code bundle accompanying the paper

Valid XHTML 1.0! Valid CSS!

Andres Löh, 2014-06-28