Proposal: New Eq and Ord instances for Double and Float
Twan van Laarhoven
twanvl at gmail.com
Fri Nov 11 13:29:10 CET 2011
On 10/11/11 18:03, Roman Leshchinskiy wrote:
> Oh, I never said it would be easy :-) But this definitely seems like the
> right thing to do to me.
> In the context of this thread, however, it would be perfectly acceptable
> if NaNs just aborted the program. The original problem was that they mess
> up things. It is implementation-defined what happens if a computation
> wants to create a NaN. We could simply say that the program is aborted by
> default, with a way to turn off this behaviour and just create a NaN.
> Raising a Haskell exception would certainly be very nice but not essential
> for this particular problem.
That seems dangerous. This is what happens now if I use unchecked div
Prelude> GHC.Base.divInt 1 0
Floating point exception
It exits ghci immediately. Having "0/0" crash would make trusting 'safe'
programs much harder. For example, I could no longer make an IRC bot for
evaluating numeric expressions, and expect it to keep running.
More information about the Libraries