[Haskell-cafe] lists as instances of a class?
Henning Thielemann
lemming at henning-thielemann.de
Mon Jul 10 10:53:12 EDT 2006
On Mon, 10 Jul 2006, David Roundy wrote:
> > class Vec v where
> > (.+.) :: v -> v -> v
>
> > instance Vec [Double] where
> > xs .+. ys = zipWith (+) xs ys
>
> > instance Vec Double where
> > x .+. y = x + y
>
>
> P.S. This is with ghc 6.4.1. And oddly enough, if you make the instance
>
> instance Num a => Vec [a] where
> xs .+. ys = zipWith (+) xs ys
What about
instance Vec a => Vec [a] where
(.+.) = zipWith (.+.)
?
More information about the Haskell-Cafe
mailing list