[Haskell-cafe] nubBy seems broken in recent GHCs
duncan.coutts at worc.ox.ac.uk
Wed Jun 10 04:58:49 EDT 2009
On Sat, 2009-06-06 at 18:39 +0200, Bertram Felgenhauer wrote:
> Interesting. This was changed in response to
> | Tue Sep 2 11:29:50 CEST 2008 Simon Marlow <marlowsd at gmail.com>
> | * #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.
> It turns out that 'elem' differs from the report version and should
> have its comparison reversed. Of course that would only ever matter
> for broken Eq instances.
> However, the report also states that the nubBy function may assume that
> the given predicate defines an equivalence relation.
> So I'm not sure there's anything to be fixed here - although backing
> out the above patch probably won't hurt anybody.
Seems to me the obvious solution is to revert the nubBy change and then
fix nub so that so that we still get nub = nubBy (==) (which is what
ticket #2528 was complaining about in the first place).
We need more SmallCheck properties for the List module! When Don and I
were testing our stream versions of the List module we uncovered several
of these little weirdnesses which were underspecified in the report, or
different between the report and common implementations. For example I
seem to recall that genericTake and take do not coincide when their
More information about the Libraries