[Haskell-beginners] (Implicit) equality testing using multiple function definitions
Tom Murphy
amindfv at gmail.com
Wed Jul 20 20:38:39 CEST 2011
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.
There has to be a reason why we've all typed "deriving (Eq)"
again and again: because sometimes we don't want, for some OurType, to
be able to express:
(a :: OurType) == (b :: OurType).
This is the source of my confusion.
Thanks for your time,
Tom
More information about the Beginners
mailing list