
On Sun, Oct 5, 2008 at 11:07 PM, David Menendez
On Sat, Oct 4, 2008 at 3:26 AM, Bart Massey
wrote: I need to know what the community wants me to do to close out my proposal to add nubOrd to the standard libraries. After ruling out a lot of marginal choices, I guess I see three leading alternatives, all of which have negatives. I'd love to have some feedback on these so I can start thinking about other things.
I realize I'm coming into this discussion late, but has anyone surveyed existing Haskell code to see how often nub is used? How many of those cases require the specific functionality of nub, as opposed to something like "Set.toList . Set.fromList"? I may be misjudging things, but I can't imagine it's often enough to justify three or more implementations in the standard library.
If there are really a lot of cases where people need a collection that (1) has no duplicates, and (2) preserves an arbitrary order of elements, maybe we'd be better off designing a data structure specifically for that.
-- Dave Menendez
nub . sort (and the reverse) are very frequent. The attached sort.txt was produced by find bin/ -name "*.hs" -exec sh -c "grep sort {} | grep nub && echo {}" \; > sort.txt It's very crude and obviously produces lots of false positives & negatives, but even so, there's at least >50 uses of nub . sort etc. -- gwern