Generic Programming with Multiple Parameters

  • José Pedro Magalhães
Conference paper

DOI: 10.1007/978-3-319-07151-0_9

Part of the Lecture Notes in Computer Science book series (LNCS, volume 8475)
Cite this paper as:
Magalhães J.P. (2014) Generic Programming with Multiple Parameters. In: Codish M., Sumii E. (eds) Functional and Logic Programming. FLOPS 2014. Lecture Notes in Computer Science, vol 8475. Springer, Cham


Generic programming, a form of abstraction in programming languages that serves to reduce code duplication by exploiting the regular structure of algebraic datatypes, has been present in the Haskell language in different forms for many years. Lately, a library for generic deriving has been given native support in the compiler, allowing programmers to write functions such as fmap that abstract over one datatype parameter generically. The power of this approach is limited to dealing with one parameter per datatype, however. In this paper, we lift this restriction by providing a generalisation of generic deriving that supports multiple parameters, making essential use of datatype promotion and kind polymorphism. We show example encodings of datatypes, and how to define a map function that operates on multiple parameters simultaneously.


Unable to display preview. Download preview PDF.

Unable to display preview. Download preview PDF.

Copyright information

© Springer International Publishing Switzerland 2014

Authors and Affiliations

  • José Pedro Magalhães
    • 1
  1. 1.Department of Computer ScienceUniversity of OxfordOxfordUK

Personalised recommendations