Double -> CDouble, realToFrac doesn't work

Dylan Thurston dpt at
Fri Nov 5 06:59:12 EST 2004

On Thu, Nov 04, 2004 at 08:32:52PM +0100, Sven Panne wrote:
> It's an old thread, but nothing has really happened yet, so I'd like to
> restate and expand the question: What should the behaviour of toRational,
> fromRational, and decodeFloat for NaN and +/-Infinity be? Even if the report
> is unclear here, it would be nice if GHC, Hugs, and NHC98 agreed on 
> something.
> Can we agree on the special Rational values below?

I would be very careful of adding non-rationals to the Rational type.
For one thing, it breaks the traditional rule for equality
  a % b == c % d     iff    a*d == b*c
You'd need to look at all the instances for Ratio a that are defined.
For instance, the Ord instance would require at least lots of special
cases.  And when would you expect 'x/0' to give +Infinity and when
-Infinity?  For IEEE floats, there are distinct representations of +0
and -0, which lets you know when you want which one.  But for the
Rational type there is no such distinction.

The behaviour that '1 % 0' gives the error 'Ratio.% : zero
denominator' is clearly specified by the Library Report.

In the meantime, there are utility functions for dealing with IEEE
floats (isNaN, etc.)

-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
Url :

More information about the Glasgow-haskell-users mailing list