[Haskell-cafe] confusion about 'instance'....

Nicholls, Mark Nicholls.Mark at mtvne.com
Thu Jan 10 09:41:13 EST 2008

> -----Original Message-----
> From: Jules Bean [mailto:jules at jellybean.co.uk]
> Sent: 10 January 2008 14:22
> To: Nicholls, Mark
> Cc: Bulat Ziganshin; haskell-cafe at haskell.org
> Subject: Re: [Haskell-cafe] confusion about 'instance'....
> Nicholls, Mark wrote:
> >
> > My confusion is not between OO classes and Haskell classes, but
> > are the members of a Haskell type class...I'd naively believed them
> > be types (like it says on the packet!)...but now I'm not so sure.
> >
> Which packet?

The packet labelled "type class"....you're from .co.uk....you should
understand my English idioms. :-) 

> Classes are not types.


> Classes are groups of types. Sets of types. Classifications of types.

I had them down as an n-ary relation on types....someone's said
something somewhere that's made me question that...but I think I
misinterpreted them....so I may default back to n-ary relation.

> For any type, you can ask the quesiton "is this type a member of this
> class, or not?"


> Without wishing to split hairs too finely, I find it a useful
> not to consider the class context "part of the type" somehow.
> So, when you see this:
> (Num a, Eq b) => a -> b -> a
> Rather than thinking of that whole thing as a type, it helps to think
> the part on the right of the => as the 'actual type' and the part on
> left of the => as "some extra constraints on the type".

Hmmm...I'm not sure that helps....it may just make me more confused.

> So you might say this has the type "a -> b -> a", providing that a is
> Num and b is an Eq.
> Jules

More information about the Haskell-Cafe mailing list