[Haskell-beginners] Type classes and synonyms

Philip Scott haskell-beginners at foo.me.uk
Sat Nov 21 12:39:20 EST 2009


Hi Stephan,

> > instance Num a => Num [a] where
> >   (+) = zipWith (+)
> >   (-) = zipWith (-)
> >   (*) = zipWith (*)
> >   fromInteger = repeat . fromInteger
> >   abs         = map abs
> >   signum      = map signum

Oooh I had no idea you could do that with 'instance'

I merge my lists into a list of pairs before I do anything with them so 
unevenness isn't a problem; I was just trying t convince haskell that I could 
use nice operators like '+' on my derived type.

Thank you very much for your reply; between that and Felipe's I have enough to 
keep me busy all evening digesting the new toys you have demonstrated :)

- Philip


More information about the Beginners mailing list