Parametric datatype-genericity

  • Authors:
  • Jeremy Gibbons;Ross Paterson

  • Affiliations:
  • Oxford University, Oxford, United Kingdom;City University, London, United Kingdom

  • Venue:
  • Proceedings of the 2009 ACM SIGPLAN workshop on Generic programming
  • Year:
  • 2009

Quantified Score

Hi-index 0.00

Visualization

Abstract

Datatype-generic programs are programs that are parametrized by a datatype or type functor: whereas polymorphic programs abstract from the "integers" in "lists of integers",datatype-generic programs abstract from the "lists of". There are two main styles of datatype-generic programming: the Algebra of Programming approach, characterized by structured recursion operators arising from initial algebras and final coalgebras, and the Generic Haskell approach, characterized by case analysis over the structure of a datatype. We show that the former enjoys a kind of higher-order naturality, relating the behaviours of generic functions at different types; in contrast, the latter is ad~hoc, with no coherence required or provided between the various clauses of a definition. Moreover, the naturality properties arise "for free", simply from the parametrized types of the generic functions: we present a higher-order parametricity theorem for datatype-generic operators.