[GHC] #15566: Implement minimumOn, maximumOn to mirror sortOn

GHC ghc-devs at haskell.org
Sat Aug 25 15:12:46 UTC 2018


#15566: Implement minimumOn, maximumOn to mirror sortOn
-------------------------------------+-------------------------------------
           Reporter:  Garciat        |             Owner:  (none)
               Type:  feature        |            Status:  new
  request                            |
           Priority:  normal         |         Milestone:  Research needed
          Component:                 |           Version:  8.5
  libraries/base                     |
           Keywords:                 |  Operating System:  Unknown/Multiple
       Architecture:                 |   Type of failure:  None/Unknown
  Unknown/Multiple                   |
          Test Case:                 |        Blocked By:
           Blocking:                 |   Related Tickets:
Differential Rev(s):                 |         Wiki Page:
-------------------------------------+-------------------------------------
 By importing Data.List, we currently get:

 {{{#!hs
 sortBy :: (a -> a -> Ordering) -> [a] -> [a]
 maximumBy :: Foldable t => (a -> a -> Ordering) -> t a -> a
 minimumBy :: Foldable t => (a -> a -> Ordering) -> t a -> a

 sortOn :: Ord b => (a -> b) -> [a] -> [a]
 }}}

 I believe sortOn to be a very useful 'shortcut'. In that spirit, I propose
 we add:

 {{{#!hs
 maximumOn :: (Foldable t, Ord b) => (a -> b) -> t a -> a
 minimumOn :: (Foldable t, Ord b) => (a -> b) -> t a -> a
 }}}

-- 
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/15566>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler


More information about the ghc-tickets mailing list