On Sun, Mar 01, 2009 at 02:30:34PM -1000, Tim Newsham wrote:
Did nubBy change recently? In 6.8.2 I could generate primes as:
nubBy (\a b -> b `mod` a == 0) [2..]
but in 6.10.1 I have to use
nubBy (\a b -> a `mod` b == 0) [2..]
Is this change intentional? If so, what is the reason?
Tue Sep 2 10:29:50 BST 2008 Simon Marlow
* #2528: reverse the order of args to (==) in nubBy to match nub
This only makes a difference when the (==) definition is not
reflexive, but strictly speaking it does violate the report definition
of nubBy, so we should fix it.
See also: http://hackage.haskell.org/trac/ghc/ticket/2528
http://www.haskell.org/onlinereport/list.html#sect17.6
The Report imposes the precondition that the relation be an equivalence,
so your use was out of spec.
Still, perhaps it would have been better to fix #2528 by changing nub
instead of nubBy. As it is the USE_REPORT_PRELUDE versions of nub and
nubBy differ from the faster versions. (And the comment on elem_by is
untrue.)