I'm curious, and have been unable to find a proposal for something like this in Haskell. Consider if sort
had been written but not sortBy
.
sortBy :: forall a. (a -> a -> Ordering) -> [a] -> [a]
sortBy f = map getX . sort . map X
where
newtype X = X { getX :: a }
instance Ord X where
compare (X a) (X b) = f a b
Has anyone seen this proposal?