SafeHaskell: Added SafeHaskell to base
[ghc.git] / libraries / base / Data / Ord.hs
1 {-# LANGUAGE Trustworthy #-}
2 {-# LANGUAGE CPP, NoImplicitPrelude #-}
3
4 -----------------------------------------------------------------------------
5 -- |
6 -- Module : Data.Ord
7 -- Copyright : (c) The University of Glasgow 2005
8 -- License : BSD-style (see the file libraries/base/LICENSE)
9 --
10 -- Maintainer : libraries@haskell.org
11 -- Stability : stable
12 -- Portability : portable
13 --
14 -- Orderings
15 --
16 -----------------------------------------------------------------------------
17
18 module Data.Ord (
19 Ord(..),
20 Ordering(..),
21 comparing,
22 ) where
23
24 #if __GLASGOW_HASKELL__
25 import GHC.Base
26 #endif
27
28 -- |
29 -- > comparing p x y = compare (p x) (p y)
30 --
31 -- Useful combinator for use in conjunction with the @xxxBy@ family
32 -- of functions from "Data.List", for example:
33 --
34 -- > ... sortBy (comparing fst) ...
35 comparing :: (Ord a) => (b -> a) -> b -> b -> Ordering
36 comparing p x y = compare (p x) (p y)