[Haskell-cafe] ordNub

Francesco Mazzoli f at mazzo.li
Sun Jul 14 13:45:49 CEST 2013


At Sun, 14 Jul 2013 07:31:05 -0400,
Clark Gaebel wrote:
> Similarly, I've always used:
> 
> import qualified Data.HashSet as S
> 
> nub :: Hashable a => [a] -> [a]
> nub = S.toList . S.fromList
> 
> And i can't think of any type which i can't write a Hashable instance, so
> this is extremely practical.

Well, the above is not stable while Niklas’ is.  But I guess that’s not
the point of your message :).

I’ve always avoided “nub” too, and FWIW I’d like a constrained version
too—maybe avoiding Data.Set so that it could live in Data.List.  I think
Ord would be much better than Hashable, since it is 1. in “base” 2. much
more established and understood.

Although if you find yourself using “nub” too much you’re probably doing
something wrong...

Francesco




More information about the Haskell-Cafe mailing list