[Haskell-cafe] Where is "minimumsBy"?

Tom Ellis tom-lists-haskell-cafe-2017 at jaguarpaw.co.uk
Wed Sep 26 10:27:33 UTC 2018

Data.List.minimumBy :: Foldable t => (a -> a -> Ordering) -> t a -> a


but there are many cases where that's quite unhelpful.  Actually what we
want is more like

    minimumsBy :: ... => (a -> a -> Ordering) -> t a -> [a]

There can be many distinct minimizers.  For example when I want to get the
collection of the youngest people from [(Age, Person)] I want

    minimumsBy (compare `on` fst) [(12, alice), (15, balaji), (12, cho)]

to return

    [(12, alice), (12, cho)]

Does "minimumsBy" exist somewhere reasonably standard?  Hoogle doesn't throw
up anything obvious




More information about the Haskell-Cafe mailing list