Portability | portable |
---|---|
Stability | stable |
Maintainer | libraries@haskell.org |
Safe Haskell | Trustworthy |
Orderings
Documentation
class Eq a => Ord a whereSource
The Ord
class is used for totally ordered datatypes.
Instances of Ord
can be derived for any user-defined
datatype whose constituent types are in Ord
. The declared order
of the constructors in the data declaration determines the ordering
in derived Ord
instances. The Ordering
datatype allows a single
comparison to determine the precise ordering of two objects.
Minimal complete definition: either compare
or <=
.
Using compare
can be more efficient for complex types.
Ord Bool | |
Ord Char | |
Ord Double | |
Ord Float | |
Ord Int | |
Ord Int8 | |
Ord Int16 | |
Ord Int32 | |
Ord Int64 | |
Ord Integer | |
Ord Ordering | |
Ord Word | |
Ord Word8 | |
Ord Word16 | |
Ord Word32 | |
Ord Word64 | |
Ord () | |
Ord TyCon | |
Ord TypeRep | |
Ord ArithException | |
Ord Fingerprint | |
Ord IOMode | |
Ord SeekMode | |
Ord CUIntMax | |
Ord CIntMax | |
Ord CUIntPtr | |
Ord CIntPtr | |
Ord CSUSeconds | |
Ord CUSeconds | |
Ord CTime | |
Ord CClock | |
Ord CSigAtomic | |
Ord CWchar | |
Ord CSize | |
Ord CPtrdiff | |
Ord CDouble | |
Ord CFloat | |
Ord CULLong | |
Ord CLLong | |
Ord CULong | |
Ord CLong | |
Ord CUInt | |
Ord CInt | |
Ord CUShort | |
Ord CShort | |
Ord CUChar | |
Ord CSChar | |
Ord CChar | |
Ord GeneralCategory | |
Ord TypeRepKey | |
Ord Associativity | |
Ord Fixity | |
Ord Arity | |
Ord IntPtr | |
Ord WordPtr | |
Ord Any | |
Ord All | |
Ord NewlineMode | |
Ord Newline | |
Ord BufferMode | |
Ord ExitCode | |
Ord ArrayException | |
Ord AsyncException | |
Ord ThreadStatus | |
Ord BlockReason | |
Ord ThreadId | |
Ord Fd | |
Ord CRLim | |
Ord CTcflag | |
Ord CSpeed | |
Ord CCc | |
Ord CUid | |
Ord CNlink | |
Ord CGid | |
Ord CSsize | |
Ord CPid | |
Ord COff | |
Ord CMode | |
Ord CIno | |
Ord CDev | |
Ord Unique | |
Ord Unique | |
Ord Version | |
(Eq [a], Ord a) => Ord [a] | |
(Eq (Ratio a), Integral a) => Ord (Ratio a) | |
Eq (Ptr a) => Ord (Ptr a) | |
Eq (FunPtr a) => Ord (FunPtr a) | |
(Eq (Maybe a), Ord a) => Ord (Maybe a) | |
(Eq (Down a), Ord a) => Ord (Down a) | |
Eq (ForeignPtr a) => Ord (ForeignPtr a) | |
(Eq (Last a), Ord a) => Ord (Last a) | |
(Eq (First a), Ord a) => Ord (First a) | |
(Eq (Product a), Ord a) => Ord (Product a) | |
(Eq (Sum a), Ord a) => Ord (Sum a) | |
(Eq (Dual a), Ord a) => Ord (Dual a) | |
Eq (Fixed a) => Ord (Fixed a) | |
(Eq (Either a b), Ord a, Ord b) => Ord (Either a b) | |
(Eq (a, b), Ord a, Ord b) => Ord (a, b) | |
(Eq (Array i e), Ix i, Ord e) => Ord (Array i e) | |
(Eq (a, b, c), Ord a, Ord b, Ord c) => Ord (a, b, c) | |
(Eq (a, b, c, d), Ord a, Ord b, Ord c, Ord d) => Ord (a, b, c, d) | |
(Eq (a, b, c, d, e), Ord a, Ord b, Ord c, Ord d, Ord e) => Ord (a, b, c, d, e) | |
(Eq (a, b, c, d, e, f), Ord a, Ord b, Ord c, Ord d, Ord e, Ord f) => Ord (a, b, c, d, e, f) | |
(Eq (a, b, c, d, e, f, g), Ord a, Ord b, Ord c, Ord d, Ord e, Ord f, Ord g) => Ord (a, b, c, d, e, f, g) | |
(Eq (a, b, c, d, e, f, g, h), Ord a, Ord b, Ord c, Ord d, Ord e, Ord f, Ord g, Ord h) => Ord (a, b, c, d, e, f, g, h) | |
(Eq (a, b, c, d, e, f, g, h, i), Ord a, Ord b, Ord c, Ord d, Ord e, Ord f, Ord g, Ord h, Ord i) => Ord (a, b, c, d, e, f, g, h, i) | |
(Eq (a, b, c, d, e, f, g, h, i, j), Ord a, Ord b, Ord c, Ord d, Ord e, Ord f, Ord g, Ord h, Ord i, Ord j) => Ord (a, b, c, d, e, f, g, h, i, j) | |
(Eq (a, b, c, d, e, f, g, h, i, j, k), Ord a, Ord b, Ord c, Ord d, Ord e, Ord f, Ord g, Ord h, Ord i, Ord j, Ord k) => Ord (a, b, c, d, e, f, g, h, i, j, k) | |
(Eq (a, b, c, d, e, f, g, h, i, j, k, l), Ord a, Ord b, Ord c, Ord d, Ord e, Ord f, Ord g, Ord h, Ord i, Ord j, Ord k, Ord l) => Ord (a, b, c, d, e, f, g, h, i, j, k, l) | |
(Eq (a, b, c, d, e, f, g, h, i, j, k, l, m), Ord a, Ord b, Ord c, Ord d, Ord e, Ord f, Ord g, Ord h, Ord i, Ord j, Ord k, Ord l, Ord m) => Ord (a, b, c, d, e, f, g, h, i, j, k, l, m) | |
(Eq (a, b, c, d, e, f, g, h, i, j, k, l, m, n), Ord a, Ord b, Ord c, Ord d, Ord e, Ord f, Ord g, Ord h, Ord i, Ord j, Ord k, Ord l, Ord m, Ord n) => Ord (a, b, c, d, e, f, g, h, i, j, k, l, m, n) | |
(Eq (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o), Ord a, Ord b, Ord c, Ord d, Ord e, Ord f, Ord g, Ord h, Ord i, Ord j, Ord k, Ord l, Ord m, Ord n, Ord o) => Ord (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o) |
The Down
type allows you to reverse sort order conveniently. A value of type
contains a value of type Down
aa
(represented as
).
If Down
aa
has an
instance associated with it then comparing two
values thus wrapped will give you the opposite of their normal sort order.
This is particularly useful when sorting in generalised list comprehensions,
as in: Ord
then sortWith by
Down
x
Down a |