#2528: nub not as reliable as nubBy
-------------------------+--------------------------------------------------
    Reporter:  jdressel  |        Owner:         
        Type:  bug       |       Status:  closed 
    Priority:  normal    |    Milestone:         
   Component:  Compiler  |      Version:  6.8.2  
    Severity:  minor     |   Resolution:  invalid
    Keywords:            |     Testcase:         
Architecture:  Unknown   |           Os:  Linux  
-------------------------+--------------------------------------------------
Changes (by JeremyShaw):

  * status:  new => closed
  * resolution:  => invalid

Comment:

 Your (==) instance is broken. Specifically, for:

 -- ((9+9)+2)
 a = Branch (Branch (Leaf (Just 9)) Add (Leaf (Just 9))) Add (Leaf (Just
 2))

 -- (9+(2+9))
 b = Branch (Leaf (Just 9)) Add (Branch (Leaf (Just 2)) Add  (Leaf (Just
 9)))

 we see that:

 *Main> a == b
 True
 *Main> b == a
 False
 *Main>

 There may be other bugs as well, that is just the first instance I found.
 nubBy (==) will break as well, you just have not seen it yet.

 All instances of Eq must be transitive, reflexive, symmetric, and
 antisymmetric. Haskell can't automatically check this for you -- so it is
 left up the developer to do, either by formal proof, or by unit testing.

-- 
Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/2528#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

Reply via email to