[GHC] #15731: Add sortOn/coerce rule

#15731: Add sortOn/coerce rule -------------------------------------+------------------------------------- Reporter: dfeuer | Owner: (none) Type: feature | Status: new request | Priority: normal | Milestone: 8.8.1 Component: Core | Version: 8.6.1 Libraries | Keywords: | Operating System: Unknown/Multiple Architecture: | Type of failure: Runtime Unknown/Multiple | performance bug Test Case: | Blocked By: Blocking: | Related Tickets: Differential Rev(s): | Wiki Page: -------------------------------------+------------------------------------- When the argument to `sortOn` is very cheap, we're better off ''not'' decorating the list. Detecting this is not easy in general, but it's trivial for coercions. We should probably offer something like {{{#!hs {-# RULES "sortOn/coerce" forall b xs. sortOn @_ @b coerce xs = sortWith (coerce @_ @b) xs #-} }}} As far as I can tell, we can't use type application directly like that, but we can go via `Proxy#`. `PrelRules` could do better, of course, catching selector functions, but I don't think we want to go that far. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/15731 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#15731: Add sortOn/coerce rule -------------------------------------+------------------------------------- Reporter: dfeuer | Owner: (none) Type: feature request | Status: new Priority: normal | Milestone: 8.8.1 Component: Core Libraries | Version: 8.6.1 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: Runtime | Unknown/Multiple performance bug | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by simonpj): I'm completely lost. What is the problem you are trying to solve? What does it mean to "decorate the list"? What is the bug you are reporting? Or is it a feature request? -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/15731#comment:1 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#15731: Add sortOn/coerce rule -------------------------------------+------------------------------------- Reporter: dfeuer | Owner: (none) Type: feature request | Status: new Priority: normal | Milestone: 8.8.1 Component: Core Libraries | Version: 8.6.1 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: Runtime | Unknown/Multiple performance bug | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by dfeuer): `sortOn` uses decorate-sort-undecorate, which is only efficient if the passed function is sufficiently expensive. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/15731#comment:2 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler
participants (1)
-
GHC