On Monday 05 October 2009 10:14:02 pm Henning Thielemann wrote: > Sönke Hahn schrieb: > > Hi! > > > > I often stumble upon 2- (or 3-) dimensional numerical data types like > > > > (Double, Double) > > > > or similar self defined ones. I like the idea of creating instances for > > Num for these types. The meaning of (+), (-) and negate is clear and very > > intuitive, i think. I don't feel sure about (*), abs, signum and > > fromInteger. I used to implement > > > > fromInteger n = (r, r) where r = fromInteger n > > > > , but thinking about it, > > > > fromInteger n = (fromInteger n, 0) > > > > seems very reasonable, too. > > > > Any thoughts on that? How would you do it? > > I use NumericPrelude that has more fine grained type classes. E.g. (+) > is in Additive and (*) is in Ring. > > http://hackage.haskell.org/package/numeric-prelude >
That is pretty cool, thanks. How do your import statements look like, when you use numeric-prelude? Mine look a bit ugly: import Prelude hiding ((+), (-), negate) import Algebra.Additive ((+), (-), negate) Sönke _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe