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

On Mon, Oct 5, 2009 at 10:36 AM, Miguel Mitrofanov
Of course, it's OK to call anything "numbers" provided that you stated explicitly what exactly you would mean by that. But then you have to drop all kind of stuff mathematicians developed for the usual notion of numbers. In the same way, you shouldn't use the "Num" class for your "numbers".
On the other hand, people can (ab)use the "Num" class as they wish, and it's their business until they ask a question about it somewhere outside - which makes the business not only theirs. [...]
The Num class has `negate' as part of its definition. Natural numbers are numbers, but I don't believe there is any sensible definition of `negate' for them. Haskell 98's numeric hierarchy combines many operations which should be separate. As further evidence, every bit of Haskell I have seen that does symbolic manipulation of numeric expressions either leaves out instances that would make the syntax more convenient, or else defines partial instances because certain class functions have no sensible definition for symbolic expressions. Sincerely, Brad

Everyone agrees that the Haskell numeric hierarchy is flawed, but I've
yet to see a good replacement.
On Mon, Oct 5, 2009 at 4:51 PM, Brad Larsen
On Mon, Oct 5, 2009 at 10:36 AM, Miguel Mitrofanov
wrote: [...] Of course, it's OK to call anything "numbers" provided that you stated explicitly what exactly you would mean by that. But then you have to drop all kind of stuff mathematicians developed for the usual notion of numbers. In the same way, you shouldn't use the "Num" class for your "numbers".
On the other hand, people can (ab)use the "Num" class as they wish, and it's their business until they ask a question about it somewhere outside - which makes the business not only theirs. [...]
The Num class has `negate' as part of its definition. Natural numbers are numbers, but I don't believe there is any sensible definition of `negate' for them.
Haskell 98's numeric hierarchy combines many operations which should be separate. As further evidence, every bit of Haskell I have seen that does symbolic manipulation of numeric expressions either leaves out instances that would make the syntax more convenient, or else defines partial instances because certain class functions have no sensible definition for symbolic expressions.
Sincerely, Brad _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe

Lennart Augustsson wrote:
Everyone agrees that the Haskell numeric hierarchy is flawed, but I've yet to see a good replacement.
That's because the "good replacement" which is mathematically sound would be a real mess to work with -- for exactly the same reason that Functor , Applicative and Monad are unrelated classes. See [1]. In a prototype language I am playing with, my version of Num depends on 15 'previous' classes, and that's likely to increase, not decrease. Jacques [1] http://repetae.net/recent/out/classalias.html
participants (3)
-
Brad Larsen
-
Jacques Carette
-
Lennart Augustsson