FP /

Concepts = Type Classes

For the last few years we have explored what C++ calls "concepts" and Haskell calls "type classes". The basic conclusion is that they are the same thing (details below).

Generic programming with C++ concepts and Haskell type classes---a comparison

J.-P. Bernardy, P. Jansson, M. Zalewski, S. Schupp

Final draft of ConceptsJFP.pdf.

Bibtex entry:

    author  = {Jean-Philippe Bernardy and Patrik Jansson and Marcin Zalewski and Sibylle Schupp},
    title   = {Generic programming with {C++} concepts and {Haskell} type classes --- a comparison},
    journal = {Journal of Functional Programming},
    volume  = {20},
    number  = {3--4},
    pages   = {271--302},
    year    = {2010},
    doi     = {10.1017/S095679681000016X},
    URL     = {http://dx.doi.org/10.1017/S095679681000016X},
    eprint  = {http://journals.cambridge.org/article_S095679681000016X}
JFP accepted the updated version (after second round of JFP reviewing)
Submitted updated version after JFP reviewing
Submitted an extended version for the JFP special issue on Generic Programming.


Earlier studies have introduced a list of high-level evaluation criteria to assess how well a language supports generic programming. Languages that meet all criteria include Haskell, because of its type classes, and C++ with the concept feature. We refine these criteria into a taxonomy that captures commonalities and differences between type classes in Haskell and concepts in C++, and discuss which differences are incidental and which ones are due to other language features. The taxonomy allows for an improved understanding of language support for generic programming, and the comparison is useful for the ongoing discussions among language designers and users of both languages.

Practical info:

  • git repo: ssh://remote12.chalmers.se/chalmers/groups/cse-set/gitroot
  • Paper + code is in the ConceptsJFP/ subdirectory
  • The earlier Workshop version is described below.

A Comparison of C++ Concepts and Haskell Type Classes

J.-P. Bernardy, P. Jansson, M. Zalewski, S. Schupp, A. Priesnitz

Published in the Proc. of the 2008 Workshop on Generic Programming

CPL: http://publications.lib.chalmers.se/cpl/record/index.xsql?pubid=72479 SMS: http://sms.cs.chalmers.se/wiki/index.php?title=Special:Publications&id=Year/2008.html

Ubuntu packages needed to "compile" the LaTeX source (if you get an error like file beramono.sty not found)

  sudo apt-get install texlive-fonts-extra