Hugs Humor
Jon Fairbairn
Jon.Fairbairn@cl.cam.ac.uk
Mon, 07 Jul 2003 17:13:53 +0100
On 2003-07-07 at 13:40+0200 Jerzy Karczmarczuk wrote:
> [...] I believe (still naďvely??) that those socio-psycho-pragmatisms
> which played some role in the definition of the language should
> be better tuned. If I were to write
>
> pi = 3.1415926536 :: Rational
>
> I suppose that I would like to see rather 355/113 or something close,
> than 3926990817/1250000000 or similar.
If it's a _Rational_, surely you want it to be exactly the
same as you get for 31415926536%10000000000?
> GHCI doesn't make me happier than Hugs:
> 221069929751607/70368744177664.
That doesn't happen for me:
Prelude> :m Ratio
Prelude Ratio> 31415926536%10000000000
3926990817 % 1250000000
Prelude Ratio> 3.1415926536::Rational
3926990817 % 1250000000
Prelude Ratio>
What did you do to get it?
> Thus, perhaps one day we might think about parametrizing
> the 'conversion' of *explicit* decimal numbers, and -- as
> some other language permit -- make it possible and
> practical to use any other base different from 10. What do
> you think?
There might be a use for that, but one can already write
0x55%2^32
so I'm not sure that there would be much call for it, given
what I say below
> Such parametrization (perhaps with some global default)
> would also help the user who permits himself to write x =
> 1.875987 :: Rational to assess the error introduced by the
> representation conversion.
I think that <decimal number> :: Rational ought not to
introduce any error at all!
As to exact v inexact numbers, in a sense we already have
that distinction. Integer and Rational are (in correct
implementations!) exact, Int, Float and Double are
inexact. One could express my objection to the design as:
relegate all inexactitudes to libraries.
Cheers,
Jón
--
Jón Fairbairn Jon.Fairbairn@cl.cam.ac.uk