#2659: Add sortOn and other *On functions
---------------------------------+------------------------------------------
Reporter: twanvl | Owner:
Type: proposal | Status: new
Priority: normal | Milestone: Not GHC
Component: libraries/base | Version: 6.9
Severity: normal | Resolution:
Keywords: | Difficulty: Unknown
Testcase: | Os: Unknown/Multiple
Architecture: Unknown/Multiple |
---------------------------------+------------------------------------------
Comment (by LouisWasserman):
Er. This function is already present in GHC.Exts:
http://www.haskell.org/ghc/docs/6.10.1/html/libraries/base/GHC-
Exts.html#v%3AsortWith
Replying to [ticket:2659 twanvl]:
> 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#comment:3>
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