#2659: Add sortBy and other *By functions
---------------------------------+------------------------------------------
    Reporter:  twanvl            |       Owner:                  
        Type:  proposal          |      Status:  new             
    Priority:  normal            |   Component:  libraries/base  
     Version:  6.9               |    Severity:  normal          
    Keywords:                    |    Testcase:                  
Architecture:  Unknown/Multiple  |          Os:  Unknown/Multiple
---------------------------------+------------------------------------------
 Almost all uses of {{{sortBy}}} are of the form {{{sortBy (comparing
 f)}}}, {{{sortBy (compare `on` f)}}} or an equivalent construction. I
 propose that we add the more convenient function {{{sortOn}}} to
 Data.List:
 {{{
 sortOn          :: Ord b => (a -> b) -> [a] -> [a]
 }}}
 For consistency for the other `By` functions we should also add an `On`
 equivalent:
 {{{
 nubOn           :: Eq b => (a -> b) -> [a] -> [a]
 deleteOn        :: Eq b => (a -> b) -> a -> [a] -> [a]
 deleteFirstsOn  :: Eq b => (a -> b) -> [a] -> [a] -> [a]
 unionOn         :: Eq b => (a -> b) -> [a] -> [a] -> [a]
 intersectOn     :: Eq b => (a -> b) -> [a] -> [a] -> [a]
 groupOn         :: Eq b => (a -> b) -> [a] -> [[a]]
 sortOn          :: Ord b => (a -> b) -> [a] -> [a]
 insertOn        :: Ord b => (a -> b) -> a -> [a] -> [a]
 maximumOn       :: Ord b => (a -> b) -> [a] -> a
 minimumOn       :: Ord b => (a -> b) -> [a] -> a
 }}}

-- 
Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/2659>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
_______________________________________________
Glasgow-haskell-bugs mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs

Reply via email to