[Haskell-cafe] How odd...
igloo at earth.li
Sat Aug 4 14:41:39 EDT 2007
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
| x == True = False
| x == False = True
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
> >> exp (log 0 * 0)
> >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.
0**y is undefined.
More information about the Haskell-Cafe