Opened 12 months ago

Last modified 9 months ago

#15731 new feature request

Add sortOn/coerce rule

Reported by: dfeuer Owned by:
Priority: normal Milestone: 8.10.1
Component: Core Libraries Version: 8.6.1
Keywords: Cc:
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: Runtime 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

"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.

Change History (3)

comment:1 Changed 12 months ago 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?

comment:2 Changed 12 months ago by dfeuer

sortOn uses decorate-sort-undecorate, which is only efficient if the passed function is sufficiently expensive.

comment:3 Changed 9 months ago by osa1


Bumping milestones of low-priority tickets.

Note: See TracTickets for help on using tickets.