Type patterns and generic classes in Haskell

Posted by finnsson on Stack Overflow See other posts from Stack Overflow or by finnsson
Published on 2010-03-12T15:38:49Z Indexed on 2010/03/12 16:07 UTC
Read the original article Hit count: 289

Filed under:
|
|

I'm trying to understand type patterns and generic classes in Haskell but can't seem to get it.

Could someone explain it in laymen's terms?

In [1] I've read that

"To apply functions generically to all data types, we view data types in a uniform manner: except for basic predefined types such as Float, IO, and ?, every Haskell data type can be viewed as a labeled sum of possibly labeled products."

and then Unit, :*: and :+: are mentioned. Are all data types in Haskell automatically versions of the above mentioned and if so how do I figure out how a specific data type is represented in terms of :*:, etc? The users guide for generic classes (ch. 7.16) at haskell.org doesn't mention the predefined types but shouldn't they be handled in every function if the type patterns should be exhaustive?

[1] Comparing Approaches to Generic Programming in Haskell, Ralf Hinze, Johan Jeuring, and Andres Löh

© Stack Overflow or respective owner

Related posts about haskell

Related posts about generics