Repository : ssh://darcs.haskell.org//srv/darcs/packages/base

On branch  : master

http://hackage.haskell.org/trac/ghc/changeset/3054cf9a85619efb66a4923367532307477db619

>---------------------------------------------------------------

commit 3054cf9a85619efb66a4923367532307477db619
Author: Paolo Capriotti <[email protected]>
Date:   Tue Jul 17 16:37:54 2012 +0100

    Move Down to Data.Ord (#7077)

>---------------------------------------------------------------

 Data/Ord.hs |   11 +++++++++++
 GHC/Exts.hs |   12 +-----------
 2 files changed, 12 insertions(+), 11 deletions(-)

diff --git a/Data/Ord.hs b/Data/Ord.hs
index 8180df2..c594c68 100644
--- a/Data/Ord.hs
+++ b/Data/Ord.hs
@@ -18,6 +18,7 @@
 module Data.Ord (
    Ord(..),
    Ordering(..),
+   Down(..),
    comparing,
  ) where
 
@@ -35,3 +36,13 @@ import GHC.Base
 comparing :: (Ord a) => (b -> a) -> b -> b -> Ordering
 comparing p x y = compare (p x) (p y)
 
+-- | The 'Down' type allows you to reverse sort order conveniently.  A value 
of type
+-- @'Down' a@ contains a value of type @a@ (represented as @'Down' a@).
+-- If @a@ has an @'Ord'@ 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: @then sortWith by 'Down' x@
+newtype Down a = Down a deriving (Eq)
+
+instance Ord a => Ord (Down a) where
+    compare (Down x) (Down y) = y `compare` x
diff --git a/GHC/Exts.hs b/GHC/Exts.hs
index 3c6605d..ff3a1d4 100755
--- a/GHC/Exts.hs
+++ b/GHC/Exts.hs
@@ -72,23 +72,13 @@ import GHC.Stack
 import Data.String
 import Data.List
 import Data.Data
+import Data.Ord
 import qualified Debug.Trace
 
 -- XXX This should really be in Data.Tuple, where the definitions are
 maxTupleSize :: Int
 maxTupleSize = 62
 
--- | The 'Down' type allows you to reverse sort order conveniently.  A value 
of type
--- @'Down' a@ contains a value of type @a@ (represented as @'Down' a@).
--- If @a@ has an @'Ord'@ 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: @then sortWith by 'Down' x@
-newtype Down a = Down a deriving (Eq)
-
-instance Ord a => Ord (Down a) where
-    compare (Down x) (Down y) = y `compare` x
-
 -- | 'the' ensures that all the elements of the list are identical
 -- and then returns that unique element
 the :: Eq a => [a] -> a



_______________________________________________
Cvs-libraries mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/cvs-libraries

Reply via email to