Skip to content

Instantly share code, notes, and snippets.

@WillNess
Last active December 18, 2015 00:09
Show Gist options
  • Select an option

  • Save WillNess/5694080 to your computer and use it in GitHub Desktop.

Select an option

Save WillNess/5694080 to your computer and use it in GitHub Desktop.
Replying to [comment:3 simonpj]: -- http://hackage.haskell.org/trac/ghc/ticket/7913
`nubBy` and `nub` are both intuitively ''left'' scans. `nub` should behave like
`concatMap fst . scanl (\(_,prevs) new-> if not (((elem new prevs))) then
([new],new:prevs) else ([],prevs)) ([],[])`.
`nub` should be the same as `nubBy (==)`.
Report is consistent in this regard, as it also defines `elem x = any (== x)`,
as well as
{{{
nubBy eq (x:xs) = x : nubBy eq (filter (\ y -> not (eq x y)) xs)
-- ^^^ older newer
}}}
Looks like it must be changed, although this will break existing code
(e.g. {{{nubBy (((==0).).rem) [2..]}}} ).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment