[Haskell-cafe] Num instances for 2-dimensional types

jerzy.karczmarczuk at info.unicaen.fr jerzy.karczmarczuk at info.unicaen.fr
Mon Oct 5 10:09:31 EDT 2009


Miguel Mitrofanov rebukes Sönke Hahn, who -:

>  wrote:
>> 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.


> Stop pretending something is a number when it's not.

Miguel Mitrofanov, please kindly stop pretending that you KNOW
what is a number, and what is not.

The numeric classes in standard Haskell are disgraceful, and the idea
that if something can be added, it is a number is bad. Vectors are not
numbers, but inventing "special" (+) for all kinds of Abelian additions
is awkward. So, people call "numbers" what they wish, and it is *their*
business. I needed to add functions (of course, without Eq nor Show
membership), I had to fake... Pairs (a,b) may be "numbers" in various
contexts, for example (value,derivative) in automatic differentiation. Or
(mainTerm,otherOrders) in some infinitesimal calculus. Or pairs (scalar,
3vector) for quaternions. 

The idea of putting fromInteger in the same class, is a design bug
(my personal opinion, of course). There are plenty of examples where
conversions from integers are legitimate, but no addition or (*)seem
natural. Or the other way round ; apparently Sönke Hahn is in that
situation, so he fakes...

Jerzy Karczmarczuk


More information about the Haskell-Cafe mailing list