De-orphan the Eq/Ord [a] instances
authorIan Lynagh <igloo@earth.li>
Mon, 23 Nov 2009 21:56:35 +0000 (21:56 +0000)
committerIan Lynagh <igloo@earth.li>
Mon, 23 Nov 2009 21:56:35 +0000 (21:56 +0000)
GHC/Base.lhs
GHC/Classes.hs

index 52d1252..2093ab6 100644 (file)
@@ -237,24 +237,6 @@ class  Monad m  where
 %*********************************************************
 
 \begin{code}
--- do explicitly: deriving (Eq, Ord)
--- to avoid weird names like con2tag_[]#
-
-instance (Eq a) => Eq [a] where
-    {-# SPECIALISE instance Eq [Char] #-}
-    []     == []     = True
-    (x:xs) == (y:ys) = x == y && xs == ys
-    _xs    == _ys    = False
-
-instance (Ord a) => Ord [a] where
-    {-# SPECIALISE instance Ord [Char] #-}
-    compare []     []     = EQ
-    compare []     (_:_)  = LT
-    compare (_:_)  []     = GT
-    compare (x:xs) (y:ys) = case compare x y of
-                                EQ    -> compare xs ys
-                                other -> other
-
 instance Functor [] where
     fmap = map
 
index af810fb..4a639b9 100644 (file)
@@ -45,6 +45,12 @@ class  Eq a  where
     x /= y               = not (x == y)
     x == y               = not (x /= y)
 
+instance (Eq a) => Eq [a] where
+    {-# SPECIALISE instance Eq [Char] #-}
+    []     == []     = True
+    (x:xs) == (y:ys) = x == y && xs == ys
+    _xs    == _ys    = False
+
 -- XXX This doesn't work:
 -- deriving instance Eq Bool
 -- <wired into compiler>:
@@ -100,6 +106,15 @@ class  (Eq a) => Ord a  where
     max x y = if x <= y then y else x
     min x y = if x <= y then x else y
 
+instance (Ord a) => Ord [a] where
+    {-# SPECIALISE instance Ord [Char] #-}
+    compare []     []     = EQ
+    compare []     (_:_)  = LT
+    compare (_:_)  []     = GT
+    compare (x:xs) (y:ys) = case compare x y of
+                                EQ    -> compare xs ys
+                                other -> other
+
 -- XXX This doesn't work:
 -- deriving instance Ord Bool
 -- <wired into compiler>: