[Haskell-cafe] Re: pi
wnoise at ofb.net
Wed Oct 10 06:46:48 EDT 2007
On 2007-10-10, jerzy.karczmarczuk at info.unicaen.fr wrote:
> ChrisK writes:
>> Putting 'pi' in the same class as the trigonometric functions is good design.
> If you wish so... But:
> Look, this is just a numeric constant.
> Would you like to have e, the Euler's constant, etc., as well, polluting
> the name space? What for?
It's there in the form (exp 1), after all. Yeah, you can get pi from
(log i), but the multi-valuedness is annoying. Not an issue with exp.
> 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...
Yes, this is an issue. I wish there were a serious plan for reworking
the numeric hierarchy for Haskell', but no one seems to interested.
I've thought about writing something up, but with it not entirely clear
what subset of MPTCs, FunDeps, and ATs will be in, that makes a design
a bit trickier.
class Exponential a where
(^) :: (Integral b) => a -> b -> a
> But it is just a numerical constant, no need to put it into a class, and
> nothing to do with the type_classing of related functions. "e" is not
> std. defined, and it doesn't kill people who use exponentials.
As I said above, it effectively is. And, after all, 1, 2, 3, are
constants of the typeclass Integral a => a,
and 0.0, 1.348, 2.579, 3.7, etc. are in Floating a => a.
So why not pi?
More information about the Haskell-Cafe