Proposal: add an order-reversing newtype to Data.Ord

ARJANEN Loïc Jean David arjanen.loic at
Sat Jul 14 18:22:28 CEST 2012

I have created a ticket for the proposal on GHC's Trac (see here: I didn't asked for the
maintainer's advice before opening a ticket given that the maintener is
libraries at and there wasn't any opposition.
Based on this list advice, I finally decided to just re-export
GHC.Exts's newtype for the proposal's purposes, so that this proposal
doesn't get bikeshedded to death on the newtype's name.


On 2012-06-28 12:01, ARJANEN Loïc Jean David wrote :
> Hello all,
> I recently noticed that despite conversations about that in this
> mailing-list, there isn't an order-reversing newtype in Data.Ord.
> That newtype would be quite useful, e.g. for reverse-sorting a list or
> a set, so I propose we add a newtype defined thusly:
>    newtype Reverse a = Reverse { fromReverse :: a } deriving (Eq)
>    instance Ord a => Ord (Reverse a) where
>       compare (Reverse x) (Reverse y) = compare y x
> I took the implementation from the Down newtype in GHC.Exts, so we
> could perhaps just re-export it.
> This will cause breakage to code already defining a type named
> Reverse, so I don't know if the damage will be important. Of course,
> the name and definition are open to discussion.
> Deadline: 12 July 2012.
> P.S. : A conversation about that took place here:
ARJANEN Loïc Jean David
"Computer science is no more about computers than astronomy is about
telescopes, biology is about microscopes, or chemistry is about
beakers and test tubes. Science is not about tools. It is about how we
use them, and what we find out when we do."
 Michael R. Fellows and Ian Parberry

More information about the Libraries mailing list