Modular generic programming with extensible superclasses

"Generics for the Masses" (GM) and "Scrap your Boilerplate" (SYB) are generic programming approaches based on some inenious applications of Haskell type classes. To achieve modularity, the GM and SYB approach have been extended by using 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.We show that none of these type class features are necessary if we use the single feature of extensible superclasses, the complement of subclass extension. We formalize type classes with extensible superclasses as the combination of a previously introduced type-passing translation scheme and a general type class framework. Our results shed some new light on the use of type classes to support generic programming.

[1]  Stephanie Weirich,et al.  Good advice for type-directed programming aspect-oriented programming and extensible generic functions , 2006, WGP '06.

[2]  Ralf Hinze,et al.  Open data types and open functions , 2006, PPDP '06.

[3]  J. Davenport Editor , 1960 .

[4]  Bruno C. d. S. Oliveira,et al.  Generics as a Library , 2006 .

[5]  Simon L. Peyton Jones,et al.  Scrap Your Boilerplate , 2003, APLAS.

[6]  Simon L. Peyton Jones,et al.  Scrap your boilerplate with class: extensible generic functions , 2005, ICFP '05.

[7]  Johan Jeuring,et al.  Dependency-style generic haskell , 2003, ICFP '03.

[8]  John C. Mitchell,et al.  On the type structure of standard ML , 1993, TOPL.

[9]  David Jeffery,et al.  Type classes in Mercury , 2000, Proceedings 23rd Australasian Computer Science Conference. ACSC 2000 (Cat. No.PR00518).

[10]  Arabellastrasse,et al.  Constraint Handling Rules ? , 1995 .

[11]  Slim Abdennadher,et al.  Operational Semantics and Confluence of Constraint Propagation Rules , 1997, CP.

[12]  Bruno C. d. S. Oliveira,et al.  "Scrap Your Boilerplate" Reloaded , 2006, FLOPS.

[13]  Robert Harper,et al.  Compiling polymorphism using intensional type analysis , 1995, POPL '95.

[14]  Mark P. Jones A system of constructor classes: overloading and implicit higher-order polymorphism , 1993, FPCA '93.

[15]  Johan Jeuring,et al.  PolyP—a polytypic programming language extension , 1997, POPL '97.

[16]  Gang Chen,et al.  Guarded recursive datatype constructors , 2003, POPL '03.

[17]  Ralf Lämmel,et al.  Scrap your boilerplate: a practical approach to generic programming , 2003 .

[18]  Simon L. Peyton Jones,et al.  Scrap your boilerplate: a practical design pattern for generic programming , 2003, TLDI '03.

[19]  François Pottier,et al.  Polymorphic typed defunctionalization and concretization , 2006, High. Order Symb. Comput..

[20]  Satish R. Thatte Semantics of type classes revisited , 1994, LFP '94.

[21]  Simon L. Peyton Jones,et al.  Type classes in Haskell , 1994, TOPL.

[22]  Philip Wadler,et al.  How to make ad-hoc polymorphism less ad hoc , 1989, POPL '89.

[23]  Peter J. Stuckey,et al.  An Overview of HAL , 1999, CP.

[24]  Martin Sulzmann Extracting programs from type class proofs , 2006, PPDP '06.

[25]  Ralf Hinze Generics for the masses , 2004, ICFP '04.

[26]  Peyton Jones,et al.  Haskell 98 language and libraries : the revised report , 2003 .

[27]  Marinus J. Plasmeijer,et al.  Language report Concurrent Clean , 1998 .