There's probably already a newtype
that flips the sense of Ord, Bounded, etc. Something along the lines of
newtype FlipOrd a = FlipOrd {unFlip :: a} deriving (Eq)
instance (Ord a) => Ord (FlipOrd a) where
compare = flip compare
instance (Bounded a) => Bounded (FlipOrd a) where
minBound = FlipOrd maxBound
maxBound = FlipOrd minBound
Where does this live in the existing Haskell packages?
Note: There's an existing Reverse
Functor
, which does something very different, and fortunately has a completely incompatible kind.
It's simply in Data.Ord
: Down
. (This doesn't have a Bounded
instance, though.)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With