Add sortOn/coerce rule
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
{-# 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.
Trac metadata
Trac field | Value |
---|---|
Version | 8.6.1 |
Type | FeatureRequest |
TypeOfFailure | OtherFailure |
Priority | normal |
Resolution | Unresolved |
Component | Core Libraries |
Test case | |
Differential revisions | |
BlockedBy | |
Related | |
Blocking | |
CC | |
Operating system | |
Architecture |