base-3.0.2.0: Basic librariesSource codeContentsIndex
Data.Ord
Portabilityportable
Stabilitystable
Maintainerlibraries@haskell.org
Description
Orderings
Synopsis
class Eq a => Ord a where
compare :: a -> a -> Ordering
(<) :: a -> a -> Bool
(<=) :: a -> a -> Bool
(>) :: a -> a -> Bool
(>=) :: a -> a -> Bool
max :: a -> a -> a
min :: a -> a -> a
data Ordering
= LT
| EQ
| GT
comparing :: Ord a => (b -> a) -> b -> b -> Ordering
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.

Methods
compare :: a -> a -> OrderingSource
(<) :: a -> a -> BoolSource
(<=) :: a -> a -> BoolSource
(>) :: a -> a -> BoolSource
(>=) :: a -> a -> BoolSource
max :: a -> a -> aSource
min :: a -> a -> aSource
show/hide Instances
Ord All
Ord Any
Ord ArithException
Ord ArrayException
Ord AsyncException
Ord Bool
Ord BufferMode
Ord CCc
Ord CChar
Ord CClock
Ord CDev
Ord CDouble
Ord CFloat
Ord CGid
Ord CIno
Ord CInt
Ord CIntMax
Ord CIntPtr
Ord CLDouble
Ord CLLong
Ord CLong
Ord CMode
Ord CNlink
Ord COff
Ord CPid
Ord CPtrdiff
Ord CRLim
Ord CSChar
Ord CShort
Ord CSigAtomic
Ord CSize
Ord CSpeed
Ord CSsize
Ord CTcflag
Ord CTime
Ord CUChar
Ord CUInt
Ord CUIntMax
Ord CUIntPtr
Ord CULLong
Ord CULong
Ord CUShort
Ord CUid
Ord CWchar
Ord Char
Ord Double
Ord ExitCode
Ord Fd
Ord Float
Ord GeneralCategory
Ord IOMode
Ord Int
Ord Int16
Ord Int32
Ord Int64
Ord Int8
Ord IntPtr
Ord Integer
Ord Ordering
Ord SeekMode
Ord ThreadId
Ord Unique
Ord Version
Ord Word
Ord Word16
Ord Word32
Ord Word64
Ord Word8
Ord WordPtr
Ord ()
(Ord a, Ord b) => Ord (a, b)
(Ord a, Ord b, Ord c) => Ord (a, b, c)
(Ord a, Ord b, Ord c, Ord d) => Ord (a, b, c, d)
(Ord a, Ord b, Ord c, Ord d, Ord e) => Ord (a, b, c, d, e)
(Ord a, Ord b, Ord c, Ord d, Ord e, Ord f) => Ord (a, b, c, d, e, f)
(Ord a, Ord b, Ord c, Ord d, Ord e, Ord f, Ord g) => Ord (a, b, c, d, e, f, g)
(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)
(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)
(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)
(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)
(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)
(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)
(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)
(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)
Ord a => Ord (Dual a)
Ord a => Ord (First a)
Ord (Fixed a)
Ord (ForeignPtr a)
Ord (FunPtr a)
Ord a => Ord (Last a)
Ord a => Ord (Maybe a)
Ord a => Ord (Product a)
Ord (Ptr a)
Integral a => Ord (Ratio a)
Ord a => Ord (Sum a)
Ord a => Ord [a]
(Ix i, Ord e) => Ord (Array i e)
(Ord a, Ord b) => Ord (Either a b)
data Ordering Source
Represents an ordering relationship between two values: less than, equal to, or greater than. An Ordering is returned by compare.
Constructors
LT
EQ
GT
show/hide Instances
comparing :: Ord a => (b -> a) -> b -> b -> OrderingSource
 comparing p x y = compare (p x) (p y)

Useful combinator for use in conjunction with the xxxBy family of functions from Data.List, for example:

   ... sortBy (comparing fst) ...
Produced by Haddock version 0.9