Move Eq/Ord Ordering instances to de-orphan them
authorIan Lynagh <igloo@earth.li>
Mon, 23 Nov 2009 19:43:10 +0000 (19:43 +0000)
committerIan Lynagh <igloo@earth.li>
Mon, 23 Nov 2009 19:43:10 +0000 (19:43 +0000)
GHC/Base.lhs
GHC/Classes.hs
GHC/Exts.hs

index 9f8d325..45ec617 100644 (file)
@@ -469,36 +469,6 @@ otherwise               =  True
 
 %*********************************************************
 %*                                                      *
-\subsection{Type @Ordering@}
-%*                                                      *
-%*********************************************************
-
-\begin{code}
--- | Represents an ordering relationship between two values: less
--- than, equal to, or greater than.  An 'Ordering' is returned by
--- 'compare'.
--- XXX These don't work:
--- deriving instance Eq Ordering
--- deriving instance Ord Ordering
--- Illegal binding of built-in syntax: con2tag_Ordering#
-instance Eq Ordering where
-    EQ == EQ = True
-    LT == LT = True
-    GT == GT = True
-    _  == _  = False
-        -- Read in GHC.Read, Show in GHC.Show
-
-instance Ord Ordering where
-    LT <= _  = True
-    _  <= LT = False
-    EQ <= _  = True
-    _  <= EQ = False
-    GT <= GT = True
-\end{code}
-
-
-%*********************************************************
-%*                                                      *
 \subsection{Type @Char@ and @String@}
 %*                                                      *
 %*********************************************************
@@ -642,16 +612,6 @@ lazy x = x
 -- sees it as lazy.  Then the worker/wrapper phase inlines it.
 -- Result: happiness
 
-
--- | The call '(inline f)' reduces to 'f', but 'inline' has a BuiltInRule
--- that tries to inline 'f' (if it has an unfolding) unconditionally
--- The 'NOINLINE' pragma arranges that inline only gets inlined (and
--- hence eliminated) late in compilation, after the rule has had
--- a good chance to fire.
-inline :: a -> a
-{-# NOINLINE[0] inline #-}
-inline x = x
-
 -- Assertion function.  This simply ignores its boolean argument.
 -- The compiler may rewrite it to @('assertError' line)@.
 
index 3e0ec7a..4409aca 100644 (file)
@@ -18,6 +18,8 @@
 module GHC.Classes where
 
 import GHC.Bool
+-- GHC.Magic is used in some derived instances
+import GHC.Magic ()
 import GHC.Ordering
 
 infix  4  ==, /=, <, <=, >=, >
@@ -41,6 +43,15 @@ class  Eq a  where
     x /= y               = not (x == y)
     x == y               = not (x /= y)
 
+-- XXX This doesn't work:
+-- deriving instance Eq Ordering
+-- Illegal binding of built-in syntax: con2tag_Ordering#
+instance Eq Ordering where
+    EQ == EQ = True
+    LT == LT = True
+    GT == GT = True
+    _  == _  = False
+
 -- | The 'Ord' class is used for totally ordered datatypes.
 --
 -- Instances of 'Ord' can be derived for any user-defined
@@ -74,6 +85,16 @@ 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
 
+-- XXX This doesn't work:
+-- deriving instance Ord Ordering
+-- Illegal binding of built-in syntax: con2tag_Ordering#
+instance Ord Ordering where
+    LT <= _  = True
+    _  <= LT = False
+    EQ <= _  = True
+    _  <= EQ = False
+    GT <= GT = True
+
 -- OK, so they're technically not part of a class...:
 
 -- Boolean functions
index 5a87974..661f5aa 100644 (file)
@@ -52,6 +52,7 @@ import Prelude
 
 import GHC.Prim
 import GHC.Base
+import GHC.Magic
 import GHC.Word
 import GHC.Int
 -- import GHC.Float