
Henning Thielemann wrote:
On Wed, 4 Aug 2010, John Meacham wrote:
The numeric classes are sort of messed up when it comes to non integral values. (not that they are perfect for other things) for instance, realToFrac doesn't preserve NaN or Infinity,
Why should realToFrac do this? NaN, Infinity and +/-0 are IEEE hacks for the common numerical applications you do with floating point numbers. These special values could be supported by floating point specific, or even IEEE specific type classes, but they should not be part of mathematically motivated type classes .
If we assume +/-Infinity, then NaN comes along too--- unless you want pure expressions to throw exceptions whenever messing with infinities in the wrong way. Silent exceptional values are evil, but throwing exceptions willy nilly is even more evil. You could argue that including the limits of the type as values in the type is wrong, but it does allow for some nice mathematics like log 0 = -Inf. -- Live well, ~wren