Proposal: Num instance for tuples

Twan van Laarhoven <[email protected]>
Newsgroups gmane.comp.lang.haskell.cvs.ghc,gmane.comp.lang.haskell.libraries
Message-ID <[email protected]>
Dear list,


One piece of utility code that I find myself writing over and over again is the 
pointwise Num instance for tuples, i.e.

     instance (Num a, Num b) => Num (a,b) where
         fromInteger x = (fromInteger x, fromInteger x)
         (a,b) + (a',b') = (a + a', b + b')
         (a,b) - (a',b') = (a - a', b - b')
         (a,b) * (a',b') = (a * a', b * b')
         negate (a,b) = (negate a, negate b)
         abs (a,b) = (abs a, abs b)
         signum (a,b) = (signum a, signum b)

I therefore propose that this instance be added to the base library. If we do 
that, the equivalent instances for (,,) (,,,) etc. should perhaps also be added, 
as well as instances for other numeric classes such as Fractional and Floating.


Discussion period: 2 weeks, ends 2012-11-01.


Twan
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.