
On Mar 18, 2007, at 8:02 PM, Donald Bruce Stewart wrote:
I propose we *do not* change the api to add the special case:
sortNub = sort . nub = map head . group . sort
and instead add a rewrite rule to Data.List to provide this optimisation.
{-# RULES "sort/nub" sort . nub = map head . group . sort #-}
So that the asymptotic complexity of my programs depends upon the firing of RULES? No thank you. I admit I reflexively type "map head . group . sort" whenever this comes up, but it gets excessively ugly---especially since groupBy and sortBy take differently-typed arguments. What I want is a simple duplicate-discarding sort, so it's obvious what's going on. I don't much care whether its internals are "map head . group . sort" or "toList . toSet" or something else; I'd be happy if an informed decision were made on my behalf once. -Jan-Willem Maessen