Skip to content

Add Down newtype wrapper for reversing orderings

In the same spirit as the newtypes in Data.Monoid, we can also add a newtype for reversing the ordering of a type:

newtype Down a = Down { getDown :: a }

instance Ord a => Ord (Down a) where
    Down x < Down y  =  y < x
    -- etc.

This newtype is especially useful in combination with sortOn (ticket #2629 (closed)).

Trac metadata
Trac field Value
Version 6.8.3
Type Bug
TypeOfFailure OtherFailure
Priority normal
Resolution Unresolved
Component libraries/base
Test case
Differential revisions
BlockedBy
Related
Blocking
CC
Operating system
Architecture
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information