[trac@galois.com: Re: [GHC] #1218: Add sortNub and sortNubBy to Data.List]

Jan-Willem Maessen jmaessen at alum.mit.edu
Sun Mar 18 21:58:30 EDT 2007

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

-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 2425 bytes
Desc: not available
Url : http://www.haskell.org/pipermail/libraries/attachments/20070318/674bf5fe/smime.bin

More information about the Libraries mailing list