@conference {CunhaPacheco:11a, title = {Algebraic Specialization of Generic Functions for Recursive Types}, booktitle = {Proceedings of the 2nd Workshop on Mathematically Structured Functional Programming - MSFP}, series = {ENTCS}, volume = {229}, number = {5}, year = {2011}, month = {April }, pages = {57{\textendash}74}, publisher = {Elsevier}, organization = {Elsevier}, address = {Grenoble, France}, abstract = {

Defining functions over large, possibly recursive, data structures usually involves a lot of boilerplate. This code simply traverses non-interesting parts of the data, and rapidly becomes a maintainability problem. Many generic programming libraries have been proposed to address this issue. Most of them allow the user to specify the behavior just for the interesting bits of the structure, and provide traversal combinators to {\textquotedblleft}scrap the boilerplate{\textquotedblright}. The expressive power of these libraries usually comes at the cost of efficiency, since runtime checks are used to detect where to apply the type-specific behavior. In previous work we have developed an effective rewrite system for specialization and optimization of generic programs. In this paper we extend it to also cover recursive data types. The key idea is to specialize traversal combinators using well-known recursion patterns, such as folds or paramorphisms. These are ruled by a rich set of algebraic laws that enable aggressive optimizations. We present a type-safe encoding of this rewrite system in Haskell, based on recent language extensions such as type-indexed type families.

}, attachments = {https://haslab.uminho.pt/sites/default/files/alcino/files/msfp08.pdf}, author = {Alcino Cunha and Hugo Pacheco} }