Hugs Humor

Jerzy Karczmarczuk
Tue, 08 Jul 2003 10:15:02 +0200

Andrew J Bromage wrote:

> On Mon, Jul 07, 2003 at 12:01:09PM +0200, Jerzy Karczmarczuk wrote:
>>I don't understand the remark that the internal arithmetic is
>>binary. Sure, it is, so what?
> The reason is that you can get the Rational representation even
> faster than using continued fractions. :-)
>     toFrac :: (RealFloat a) => a -> Rational
>     toFrac x
>         | m == 0    = 0
>         | otherwise = fromInteger m * 2^^(toInteger n)
>         where (m,n) = decodeFloat x
>     Prelude> toFrac 0.1
>     13421773 % 134217728

But I knew that, as anybody else. And *this* is what worries me. I am not sure
that what we really need in this context is just speed... Or even the *ultimate*

Do you mind a Polish historical/religious anecdote?

There was once upon a time, some 500 years ago, a painter called Kmita. A very
good Christian, very pious and correct. He painted mainly the Trinity members,
ocasionally Virgin Mary, and some saints. And when he painted God Father,
he did it on his knees, so strong was his faith and catholic worship.

Finally our Lord got annoyed. He descended from the painting, looked upon the
kneeled Kmita, and said:
"You, Kmita! Don't paint me on your knees! Paint me WELL!"


Jon Fairbairn comments my complaint:

 >>GHCI doesn't make me happier than Hugs:
 > 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?

I should have been more precise: your, the last value comes
from Ghci, and I obtained it as well. The first one is the outcome
of Hugs (old version, Feb. 2001).

About exact/inexact 'pi' = 3.1415926536

 > If it's a _Rational_, surely you want it to be exactly the
 > same as you get for 31415926536%10000000000?

No. If 'you' means concretely me, then no. Simply no.
pi = 3.1415926536 :: Rational

and expecting to continue the computations with an exact fraction
31415926536%10000000000, with the well known explosion of Nums &
Dens seems pragmatically silly.

I stop here, since there is nothing to say. If the Language Report
says that the construction:     v = ZZZZZZZZZZ :: Rational
is to be *exact*, whatever ZZZZZZZZZZ may be, let it be. Tu l'as
voulu, Georges Dandin. I see that people are abhorred by the
perspective of seeing it as a demand for - possibly approximate -
conversion. I am abhorred by the fact that adding ...  :: Rational
changes the lexical meaning of a literal.

Thank you for inspiring discussion.

Jerzy Karczmarczuk
Caen, France