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

  * status:  closed => reopened
  * component:  Compiler => libraries/base
  * resolution:  invalid =>

Comment:

 (From Adrian Hey)

 Well there still seems to be a problem, considering the what the library
 docs say about nubBy..

 "The 'nubBy' function behaves just like 'nub', except it uses a user-
 supplied equality predicate instead of the overloaded '==' function."

 ..and nub was indeed originally defined as,..

 {{{
 nub=nubBy compare
 }}}

 ..as is the local nub in the example.

 So right or wrong, shouldn't we see the same result in each case? Here's
 the source of the problem I think:

 {{{
 elem_by :: (a -> a -> Bool) -> a -> [a] -> Bool
 elem_by _  _ []         =  False
 elem_by eq y (x:xs)     =  x `eq` y || elem_by eq y xs
 }}}

 vs.

 {{{
 elem _ []       = False
 elem x (y:ys)   = x==y || elem x ys
 }}}

 Also, where does the H98 report say all instances of Eq must be
 transitive, reflexive, symmetric, and antisymmetric? It just says "The Eq
 class provides equality (==)..", whatever that might mean :-)

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