[GHC] #14524: Use sortOn instead of sortWith

#14524: Use sortOn instead of sortWith -------------------------------------+------------------------------------- Reporter: AndreasK | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 8.2.1 Keywords: | Operating System: Unknown/Multiple Architecture: | Type of failure: Other Unknown/Multiple | Test Case: | Blocked By: Blocking: | Related Tickets: Differential Rev(s): | Wiki Page: -------------------------------------+------------------------------------- `sortWith`provides the same functionality as `sortOn` from `Data.List`. As sortOn is already part of Prelude it makes sense for the GHC source to use it as well. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/14524 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#14524: Use sortOn instead of sortWith -------------------------------------+------------------------------------- Reporter: AndreasK | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 8.2.1 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: Other | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by nomeata): `SortOn` is there since 4.8, which, according to https://ghc.haskell.org/trac/ghc/wiki/Commentary/Libraries/VersionHistory corresponds to GHC-7.10.1 – oh yes, this is definitely around for long enough. A differential revision with that change is will probably be well- received. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/14524#comment:1 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#14524: Use sortOn instead of sortWith -------------------------------------+------------------------------------- Reporter: AndreasK | Owner: AndreasK Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 8.2.1 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: Other | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Phab:D4233 Wiki Page: | -------------------------------------+------------------------------------- Changes (by AndreasK): * owner: (none) => AndreasK * differential: => Phab:D4233 -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/14524#comment:2 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#14524: Use sortOn instead of sortWith -------------------------------------+------------------------------------- Reporter: AndreasK | Owner: AndreasK Type: bug | Status: closed Priority: normal | Milestone: Component: Compiler | Version: 8.2.1 Resolution: wontfix | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: Other | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Phab:D4233 Wiki Page: | -------------------------------------+------------------------------------- Changes (by AndreasK): * status: new => closed * resolution: => wontfix Comment: The patch increased allocations (slightly) when compiling files. Doing a quick benchmark to check if/how much faster it is showed that: `sortWith` is at least still faster when the given function is a simple pattern match like the function below for any reasonably sized list. When testing up to 500 000 elements sortWith beat sortOn by >10% consistently. Even more so when it's just a selector like `\(a,_,_) -> a`. {{{ f:: T -> T -> T -> Int f _ A A = 1 f B _ _ = 2 f C _ C = 3 f D _ _ = 4 f _ C B = 7 f A E A = 8 f _ _ _ = 5 }}} So using `sortWith` by default in GHC is the right call. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/14524#comment:3 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler
participants (1)
-
GHC