[Haskell-beginners] Typeclasses and generic types

Christopher Howard christopher.howard at frigidcode.com
Tue May 10 06:01:48 CEST 2011


On 05/09/2011 07:44 PM, Elvio Toccalino wrote:
> One further addendum to the answer provided by Arlen:
> 
> Notice that
> 
> instance Eq Point where
>   (==) a b = getX a == getX b && getY a == getY b
> 
> is defining equality between 'Point a' (as well pointed out by Arlen),
> but it does so in terms of equality test between 'a'... but there's no
> declaration in your code stating that 'a' can be equated.
> This all boils does to the following instance declaration:
> 
> instance Eq a => Eq (Point a) where ...
> 
> which reads nicely :)
> 

Ah... Makes perfect sense now. Thanks! I'm glad I finally got around to
joining this mailing list.

-- 
frigidcode.com
theologia.indicium.us



More information about the Beginners mailing list