Proposal #2659: Add sortOn and friends to Data.List
apfelmus at quantentunnel.de
Tue Oct 7 05:44:24 EDT 2008
Twan van Laarhoven wrote:
> -- Proposal--
> Ticket: #2659 (for sortOn and friends)
> Ticket: #2660 (for Down newtype)
> Deadline: now+2 weeks = 2008-10-20
> 1. should sortOn be added to Data.List?
> 2. should all other *On functions be added as well?
> 3. what name should these functions get?
> 4. should the sortOn' variations be added? What about the naming?
> 5. should Down be added to Data.Ord?
-1 concerning sortOn and friends
I think that
sortBy (comparing f)
is a very good and modular name for the functionality intended, no need
to create another one. The only advantage of a special sortOn function
would be that you can document it, i.e. there's no haddock blurb for
sortBy (comparing f) .
Hm, though sortOn could be useful if it caches the values of f by
default, like the sortOn' proposed. But Jean-Philippe's code is a
beautiful solution for this situation.
+1 concerning Down,
but I don't like the name. In particular I don't like the "get" prefix
in "getDown". I'd simply use
newtype Desc a = Desc a
without label or fromDesc if really necessary.
More information about the Libraries