[Haskell-beginners] Typeclasses vs. Data
David Place
d at vidplace.com
Thu Jul 21 15:24:34 CEST 2011
On Jul 21, 2011, at 9:09 AM, Felipe Almeida Lessa wrote:
> It is less polymorphic because 'k' has a rigid, defined type. Its
> type was chosen by the one who called the function. He gave you some
> 'k' that satisfy the class constraint, but you don't know which one.
I think that Thomas made an interesting step in his first post that may explain the problem. First, he created a type that had (or would eventually have had) constructors for each of the different kinds of continuations. This type is proper type in the mind of the type inference algorithm. Then, in the interest of modularity, he substituted a class for the type. The class is not a proper type, so the substitution doesn't work.
I remember going through this same confusion coming from a more object-oriented way of thinking. A class in Haskell is more like an interface or a protocol in object-oriented languages. I think of it as an orthogonal construct to type.
____________________
David Place
Owner, Panpipes Ho! LLC
http://panpipesho.com
d at vidplace.com
More information about the Beginners
mailing list