Proposal: Add Data.List.sortNub and sortNubBy

Neil Mitchell ndmitchell at
Tue Mar 13 19:31:47 EDT 2007


>     nubSorted :: Eq a => [a] -> [a]
>     nubSorted (x1:x2:xs)
>      | x1 == x2 = nubSorted (x1:xs)
>     nubSorted (x:xs) = x : nubSorted xs
>     nubSorted [] = []

I considered this, but nubSorted imposes a precondition, sortNub
ensures a postcondition. As an interface goes sortNub is harder to get

Plus sortNub is likely to be substantially more efficient than
nubSorted . sort - to the point where nubSorted . sort is likely to be
slower than a normal nub.



More information about the Libraries mailing list