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?

btw: These are two examples i looked at in hackage:
Data.Complex.Complex (which is special, cause it is mathematically defined, 
what (*), abs, signum and fromInteger should do (i think))

and

Physics.Hipmunk.Common.Vector 
(http://hackage.haskell.org/packages/archive/Hipmunk/5.0.0/doc/html/Physics-
Hipmunk-Common.html#9)


Sönke
_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to