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

Brad Larsen brad.larsen at gmail.com
Mon Oct 5 10:51:39 EDT 2009

On Mon, Oct 5, 2009 at 10:36 AM, Miguel Mitrofanov
<miguelimo38 at yandex.ru> 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.


More information about the Haskell-Cafe mailing list