[Haskell-cafe] Newbie question about tuples

Henning Thielemann lemming at henning-thielemann.de
Thu Jul 12 15:24:24 EDT 2007


On Thu, 12 Jul 2007, Andrew Coppin wrote:

> peterv wrote:
>
> > Q3) Suppose I want to declare an instance of Num on all tuple types having
> > (Num instances) as elements; is this possible?
> >
> > I tried
> >
> >        instance Num a => Num (a,a) where .
> >
> > but this fails
> >
> > I also tried
> >
> >        instance Num a => Num ((,) a a) where .
> >
> > but that also fails.
>
> I tried to do this a while ago and couldn't figure out how. :-(

The new approach of peterv using

  data Vector2 a = Vector2 a a

 is more sane.


More information about the Haskell-Cafe mailing list