
#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