[Haskell-beginners] (Implicit) equality testing using multiple function definitions

Brent Yorgey byorgey at seas.upenn.edu
Wed Jul 20 23:04:22 CEST 2011


On Wed, Jul 20, 2011 at 02:38:39PM -0400, Tom Murphy wrote:
> On 7/18/11, Brandon Allbery <allbery.b at gmail.com> wrote:
> [...]
> >
> > "Circumvents"?  You make it sound like the point of typeclasses is to
> > restrict things.  In fact, the point is to *undo* the restrictions
> > necessarily introduced by polymorphism:  if you don't know the type of
> > something, you don't know what you can do with it.  Typeclasses let us say
> > "this can be any type, but we need to be able to do <x> with it".  They
> > don't circumvent; they *add*.
> >
> 
>      I wish I could think of a good example. Since I can't, I'll just
> try and make my point: In a way, the point of typeclasses _is_ to
> restrict things: one of the things that typeclasses enables is a
> compile-time error if I, say, try and add Bools: by not giving Bool a
> Num instance, we're expressing that something can't be expressed.

I think you are both right.  There's a duality here, depending on your
point of view.  Consider a function type

  blah :: Foo a => ... a ...



More information about the Beginners mailing list