#4019: deriving Ord can produce incorrect and inefficient instances
---------------------------------+------------------------------------------
Reporter: rl | Owner:
Type: bug | Status: new
Priority: normal | Component: Compiler
Version: 6.13 | Keywords:
Os: Unknown/Multiple | Testcase:
Architecture: Unknown/Multiple | Failure: Incorrect result at runtime
Patch: 0 |
---------------------------------+------------------------------------------
Comment(by rl):
Here is another comment of mine from that thread.
Let's look at pairs as an example. At the moment, (>) is implemented
basically like this:
{{{
(a,b) > (c,d) = case compare a c of
LT -> False
EQ -> compare b d
GT -> True
}}}
Of course, this means that (0/0,'a') > (0/0,'a'). So we could change the
implementation:
{{{
(a,b) > (c,d) = a > c || (a == c && b > d)
}}}
But now we compare a to c twice which is very bad for, say, ([Int],Int).
Clearly, we want to use the first definition but it leads to inconsistent
results for Doubles. I don't see how to solve this while keeping IEEE
semantics of silent !NaNs.
--
Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/4019#comment:1>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
_______________________________________________
Glasgow-haskell-bugs mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs