jerzy.karczmarczuk at info.unicaen.fr jerzy.karczmarczuk at info.unicaen.fr
Wed Oct 10 16:52:36 EDT 2007

```David Roundy:

> jerzy.karczmarczuk:

>> The power is an abomination for a mathematician. With rational exponent it
>> may generate algebraic numbers, with any real - transcendental... The
>> splitting should be more aggressive. It would be good to have *integer*
>> powers, whose existence is subsumed by the multiplicative s.group structure.
>> But the Haskell standard insists that the exponent must belong to the same
>> type as the base...
>
> I suppose you're unfamiliar with the (^) operator, which does what you
> describe?

Sorry for being imprecise. I know (^), certainly, I wanted to suggest that
the power should THEN belong to Num; if a multiplication is defined, surely
the integer power as well, although this is somewhat delicate, since (*)
defines a semi-group. That's why (^) for negative exponent, yells.
And that's why we have also (^^) for Fractionals, which calls recip for
the negative exponent.

> ... Where is the abomination here?

Having THREE different power operators, one as a class member, others as
normal functions. Do you think this is methodologically sane?

=======
Other message:

> Would you also prefer to eliminate sqrt and log? We've been using these
> functions for years (in other languages)... I think it's quite sensible,
> for instance, that passing a negative number as the first argument of
> (**) with the second argument non-integer leads to a NaN.

As you wish. But, since this is an overloaded class member, making it
sensitive to the exponent being integer or not, is awkward. And perhaps
I would *like* to see the result being complex, non NaN?
Oh, you will say that it would break the typing. NaN also does it, in
a sense. And this suggests that the type a->a->a is perhaps a wrong choice.
Of course, this implies a similar criticism of log and sqrt...
(One of my friends embeds the results of his functions in a generalization
of Maybe [with different Nothings for different disasters], and a numerical
result, if available, is always sound.)

I am not sure whether Henning's ideas convince me entirely, and his
statement "In mathematical notation we don't respect types" seems to be
perhaps too strong (unless 'notation' means just the notation, which
doesn't "respect anything"), but the relation between mathematical domains
and the type system should one day be sanitized.

Jerzy Karczmarczuk

```