realToFrac issues

Lennart Augustsson lennart at augustsson.net
Tue Feb 28 08:20:45 EST 2006


Cale Gibbard wrote:
> This change means that Rational is no longer a field. It makes me feel
> uneasy at least. Should we really expect realToFrac to propagate those
> values? Look at its type:
> realToFrac     :: (Real a, Fractional b) => a -> b
> Nothing about the Fractional class would seem to indicate that NaN and
> +-Infinity should be representable. In fact, it just looks like the
> basic field operations, and fields don't tend to have such elements
> (not that we require the field axioms to hold for every instance).

I know for a fact that the Ratio type excludes 1%0 and 0%0 from the
allowed values by design rather than by mistake.  I discussed it with
Joe Fasel many years ago, and he convinced me it was a bad idea.

But I admit that the realToFrac argument carries some weight, even
if I had never even thought about the problem before.

	-- Lennart




More information about the Haskell-prime mailing list