[Haskell-cafe] Generics Versus Parametric Polymorphism

Sean Leather leather at cs.uu.nl
Wed Mar 11 06:06:44 EDT 2009

Hi Mark,

> Just wondering if Generics and Parametric polymorphism are one and the same
> in Haskell.
> I read (somewhere!) an article stating that generics might be included in
> Haskell Prime but I thought that they’re already included as parametric
> polymorphism.
To see the current status of Haskell Prime, visit the Trac page:


> Did I misread something? Or is generics in Haskell referring to something
> completely different.
I'm not sure which article you read, but there is a lot of ambiguity in the
term "generics." Depending on whom you talk to, it means a different thing.
But I can give you some pointers to where you can learn about many of the
possible interpretations.

The following paper gives a useful vocabulary for describing the different
types of "generics." Just by reading section 2 you can see how confusing it
is when so many techniques are referred to as generic programming. For
example, parametric polymorphism is an example of genericity by type here.
In the Haskell world, (as Don said) it's not considered generics, but in
Java (as Alp remarked), it's called generics.


There's a comparison paper from 2003 that presents language support for
generics in C++, ML, Haskell, Eiffel, Java, and C#. Things have changed a
bit since then, but it's an interesting read.


"Generics" in Haskell has come to be known as datatype-generic programming.
In the past, it has been labeled polytypism, structural polymorphism, or
typecase. This refers to the technique of writing functions or programs that
work for many types and have knowledge about the structure of the type
(mentioned by Bulat).

Generic Haskell is a (non-standard) language extension to Haskell. It was
used to explore the possibilities of datatype-generic programming (DGP) with
Haskell. The following paper compares varying approaches of DGP to Generic


In the last few years, people have seen the power of Haskell's type system,
and GHC has developed some interesting extensions to that type system. As a
result of this and the difficulty with maintaining language extensions
external to a compiler (e.g. Generic Haskell), libraries for DGP in Haskell
have become much more common and powerful. The following article compares a
large number of these libraries.


Lastly, since I started working in this area over a year ago, I've been
collecting references to published research. My citations are on CiteULike:


There are tags for "generics" and "datatype-generic" that give you a
narrower view on the collection.


Hope this helps to answer your questions.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090311/fe191dfa/attachment.htm

More information about the Haskell-Cafe mailing list