[Haskell-cafe] Re: Implementing "unionAll"

Ben Millwood haskell at benmachine.co.uk
Thu Feb 18 11:04:57 EST 2010


On Thu, Feb 18, 2010 at 8:07 AM, Evan Laforge <qdunkan at gmail.com> wrote:
> And BTW again, here's something I've occasionally found useful:
>
> -- | Handy to merge or sort a descending list.
> reverse_compare :: (Ord a) => a -> a -> Ordering
> reverse_compare a b = case compare a b of
>    LT -> GT
>    EQ -> EQ
>    GT -> LT

I wondered why there wasn't one of these in the standard library until
someone pointed out to me that

reverse_compare = flip compare

which actually takes fewer characters to type :P


More information about the Haskell-Cafe mailing list