
Alexander Dunlap wrote:
This seems like a good idea but it's kind of strange to have three different exposed versions of nub. Would it be possible to hide them, hide the StopList typeclass and use {-# RULES #-} pragmas to use the faster versions when possible?
I don't think that using RULES pragmas is a good solution to the problem. Instead, there's an old-fashioned way to use the name nub for all cases: make it a member of the Eq typeclass! class Eq a where (==) :: a -> a -> Bool (/=) :: a -> a -> Bool nub :: [a] -> [a] nub = -- default definition Now, nub can be specialized at will. Changing the default definition of nub to use Set if we have an Ord class is tricky, though. Basically, we would need this proposal: http://www.haskell.org/haskellwiki/Class_system_extension_proposal#Allowing_... Does it have a formal definition yet and guarantees that it works? In any case, consider nub to be another example for the usefulness of this proposal. Regards, apfelmus