
-1 for the same reason, there is no canonical interpretation of 1 as a tuple (could be (1,1), (0,1), (1,0) or s.th. else, no obvious choice...) On 18.10.2012 12:25, Simon Hengel wrote:
On Thu, Oct 18, 2012 at 11:58:17AM +0200, Twan van Laarhoven wrote:
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.
While I see *some* value in being able to perform addition, etc. on tuples, I still think that e.g. something like
fst (2 :: Point)
can easily lead to code obfuscation.
For that reason, -1.
Cheers, Simon
_______________________________________________ Libraries mailing list Libraries@haskell.org http://www.haskell.org/mailman/listinfo/libraries
-- Andreas Abel <>< Du bist der geliebte Mensch. Theoretical Computer Science, University of Munich Oettingenstr. 67, D-80538 Munich, GERMANY andreas.abel@ifi.lmu.de http://www2.tcs.ifi.lmu.de/~abel/