On Sun, Jul 14, 2013 at 7:31 AM, Clark Gaebel <cgae...@uwaterloo.ca> 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. > This won't yield results lazily (e.g. nub (repeat 'x') = _|_ instead of 'x' : _|_), but Niklas' ordNub will. His ordNub can be translated directly to HashSet and still have the stability and laziness properties. A difficulty with putting ordNub in Data.List is that it depends on containers, which is outside of the base package. Some options: * Move the implementation of Set to base. * Implement a lean version of Set in base that only provides 'insert' and 'member'. * Define ordNub in Data.Set instead. Adding a Hashable-based nub to base would be even more problematic, since you'd need Hashable in base.
_______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe