
On Sat, Aug 04, 2007 at 04:38:08PM +0100, Andrew Coppin wrote:
BTW, I recently had some code like this:
foo x | x < 0 = ... | x == 0 = ... | x > 0 = ...
I was most perplexed when I got a "non-exhaustive patterns" exception... It turns out there was a NaN in there. I forget about that.
If you use guards then you can get non-exhaustive pattern warnings anyway, e.g.: myNot x | x == True = False | x == False = True gives Warning: Pattern match(es) are non-exhaustive In the definition of `myNot': Patterns not matched: _ as it is (in general) undecidable whether all patterns are covered.
While working through this I also came across the following case which technically is a bug:
0 ** 0 1.0
exp (log 0 * 0) NaN
I suspect that GHCi is using a built-in exponentiation operator that doesn't quite conform to the standard in this case.
Hmm, according to the report the Floating class has a default method x ** y = exp (log x * y) but the Double instance is just instance Floating Double where ... so could define something different. 6.4.3 says 0**y is undefined. Thanks Ian