base-4.2.0.0: Basic librariesContentsIndex
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 where

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 -> Ordering
(<) :: a -> a -> Bool
(>=) :: a -> a -> Bool
(>) :: a -> a -> Bool
(<=) :: a -> a -> Bool
max :: a -> a -> a
min :: a -> a -> a
data Ordering
Constructors
LT
EQ
GT
comparing :: Ord a => (b -> a) -> b -> b -> Ordering
 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 2.6.0