
Generics.EMGM.Functions.Compare  Portability  nonportable  Stability  experimental  Maintainer  generics@haskell.org 





Description 
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.


Synopsis 




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.
 Constructors   Instances  



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.



Equal to. Returns x == y.



Not equal to. Returns x /= y.


Less than, greater than


These functions are equivalent to (<), (<=), (>), and (>=) when
deriving Ord.



Less than. Returns x < y.



Less than or equal to. Returns x <= y.



Greater than. Returns x > y.



Greater than or equal to. Returns x >= y.


Minimum and maximum


These functions are equivalent to functions of the same name when
deriving Ord.



The minimum of two values.



The maximum of two values.


Produced by Haddock version 2.4.2 