Proposal: Add Data.List.sortNub and sortNubBy

John Meacham john at repetae.net
Tue Mar 13 13:25:44 EDT 2007


On Tue, Mar 13, 2007 at 11:12:40AM +0000, Neil Mitchell wrote:
> As for Stefan's ordNub, I think it is a great idea to add along with
> sortNub - this really does give people a nicer set of Nub functions.
> My only worry is that the dependency on State and Set will make the
> implementation have cyclic dependency fun.

once we have ordNub, we can create lots of RULES like the following

{-# RULES "nub/ordNub" nub = ordNub :: [String] -> [String] #-} 
{-# RULES "nub/ordNub" nub = ordNub :: [Int] -> [Int] #-} 
{-# RULES "nub/ordNub" nub = ordNub :: [Integer] -> [Integer] #-} 

actually, we probably want one that uses IntMap for ints. it is
signifigantly faster.


I don't suppose there is a way to match a RULE to a class constraint? I
don't see how it would be implemented in any easy way since classes get
desugared away pretty early... but it would be an interesting feature..

{-# RULES "nub/ordNub" forall (a::*) . Ord a => nub = ordNub :: [a] -> [a] #-} 
or something...

        John

-- 
John Meacham - ⑆repetae.net⑆john⑈


More information about the Libraries mailing list