[GHC] #9004: Add sortOn function to Data.List

#9004: Add sortOn function to Data.List -------------------------------------------+------------------------------- Reporter: JohnWiegley | Owner: Type: feature request | Status: new Priority: normal | Milestone: 7.10.1 Component: libraries/base | Version: 7.8.2 Keywords: | Operating System: Architecture: Unknown/Multiple | Unknown/Multiple Difficulty: Easy (less than 1 hour) | Type of failure: Blocked By: | None/Unknown Related Tickets: | Test Case: | Blocking: -------------------------------------------+------------------------------- The following passed for two weeks on the libraries mailing list without any dissenting votes. The request is to add the following function to Data.List: {{{ -- | Sort a list by comparing the results of a key function applied to each -- element. @sortOn f@ is equivalent to @sortBy . comparing f@, but has the -- performance advantage of only evaluating @f@ once for each element in the -- input list. This is called the decorate-sort-undecorate paradigm, or -- Schwartzian transform. sortOn :: Ord b => (a -> b) -> [a] -> [a] sortOn f = map snd . sortBy (comparing fst) . map (\x -> let y = f x in y `seq` (y, x)) }}} -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9004 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#9004: Add sortOn function to Data.List -------------------------------+------------------------------------------- Reporter: | Owner: JohnWiegley | Status: patch Type: feature | Milestone: 7.10.1 request | Version: 7.8.2 Priority: normal | Keywords: Component: | Architecture: Unknown/Multiple libraries/base | Difficulty: Easy (less than 1 hour) Resolution: | Blocked By: Operating System: | Related Tickets: Unknown/Multiple | Type of failure: | None/Unknown | Test Case: | Blocking: | -------------------------------+------------------------------------------- Changes (by bernalex): * status: new => patch -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9004#comment:1 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#9004: Add sortOn function to Data.List -------------------------------+------------------------------------------- Reporter: | Owner: JohnWiegley | Status: patch Type: feature | Milestone: 7.10.1 request | Version: 7.8.2 Priority: normal | Keywords: Component: | Architecture: Unknown/Multiple libraries/base | Difficulty: Easy (less than 1 hour) Resolution: | Blocked By: Operating System: | Related Tickets: Unknown/Multiple | Type of failure: | None/Unknown | Test Case: | Blocking: | -------------------------------+------------------------------------------- Comment (by bernalex): I forgot to add the bug number to the commit message. Please use the latter patch. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9004#comment:2 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#9004: Add sortOn function to Data.List
-------------------------------+-------------------------------------------
Reporter: | Owner:
JohnWiegley | Status: patch
Type: feature | Milestone: 7.10.1
request | Version: 7.8.2
Priority: normal | Keywords:
Component: | Architecture: Unknown/Multiple
libraries/base | Difficulty: Easy (less than 1 hour)
Resolution: | Blocked By:
Operating System: | Related Tickets:
Unknown/Multiple |
Type of failure: |
None/Unknown |
Test Case: |
Blocking: |
-------------------------------+-------------------------------------------
Comment (by Herbert Valerio Riedel

#9004: Add sortOn function to Data.List -------------------------------+------------------------------------------- Reporter: | Owner: JohnWiegley | Status: closed Type: feature | Milestone: 7.10.1 request | Version: 7.8.2 Priority: normal | Keywords: Component: | Architecture: Unknown/Multiple libraries/base | Difficulty: Easy (less than 1 hour) Resolution: fixed | Blocked By: Operating System: | Related Tickets: Unknown/Multiple | Type of failure: | None/Unknown | Test Case: | Blocking: | -------------------------------+------------------------------------------- Changes (by hvr): * status: patch => closed * resolution: => fixed -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9004#comment:4 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#9004: Add sortOn function to Data.List -------------------------------------+------------------------------------- Reporter: JohnWiegley | Owner: Type: feature request | Status: closed Priority: normal | Milestone: 7.10.1 Component: libraries/base | Version: 7.8.2 Resolution: fixed | Keywords: report- Operating System: Unknown/Multiple | impact Type of failure: None/Unknown | Architecture: Blocked By: | Unknown/Multiple Related Tickets: | Test Case: | Blocking: | Differential Revisions: -------------------------------------+------------------------------------- Changes (by hvr): * cc: ekmett (added) * keywords: => report-impact -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9004#comment:5 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler
participants (1)
-
GHC