Portability  nonportable 

Stability  experimental 
Maintainer  generics@haskell.org 
Summary: Generic functions for comparing two values in different ways.
The fundamental function here is compare
, a function that returns the
Ordering
of two values (less than, equal to, or greater than). It uses the
same lexicographical ordering as deriving Ord
(e.g. left alternative of a
sum is less than the right alternative, the first component of a product is
compared first while the second is only compared if the first is equal,
etc.).
All of the remaining functions are simply derived (in the most obvious way)
from compare
. All of these functions are equivalent to methods in the Eq
and Ord
type classes. The difference with using this approach vs. deriving
(Eq, Ord)
is that you can write adhoc cases for certain datatypes while
most of the functionality is handled generically.
 newtype Compare a = Compare {
 selCompare :: a > a > Ordering
 compare :: Rep Compare a => a > a > Ordering
 eq :: Rep Compare a => a > a > Bool
 neq :: Rep Compare a => a > a > Bool
 lt :: Rep Compare a => a > a > Bool
 lteq :: Rep Compare a => a > a > Bool
 gt :: Rep Compare a => a > a > Bool
 gteq :: Rep Compare a => a > a > Bool
 min :: Rep Compare a => a > a > a
 max :: Rep Compare a => a > a > a
Compare
compare
is equivalent to the function of the same name when deriving
Ord
. All other comparison functions in this module are derived from
compare
.
The type of a generic function that takes two values of the same type and
returns an Ordering
.
Compare  

compare :: Rep Compare a => a > a > OrderingSource
Compare two values and return an Ordering
(i.e. LT
, GT
, or EQ
).
This is implemented exactly as if the datatype was deriving Ord
.
Equality, inequality
These functions are equivalent to (==)
and (/=)
when deriving Eq
.
Less than, greater than
These functions are equivalent to (<)
, (<=)
, (>)
, and (>=)
when
deriving Ord
.
Minimum and maximum
These functions are equivalent to functions of the same name when
deriving Ord
.