De-orphan the Eq/Ord Bool instances
authorIan Lynagh <igloo@earth.li>
Mon, 23 Nov 2009 20:18:17 +0000 (20:18 +0000)
committerIan Lynagh <igloo@earth.li>
Mon, 23 Nov 2009 20:18:17 +0000 (20:18 +0000)
GHC/Base.lhs
GHC/Classes.hs

index 45ec617..c1db364 100644 (file)
@@ -434,30 +434,6 @@ mapFB c f x ys = c (f x) ys
 %*********************************************************
 
 \begin{code}
--- |The 'Bool' type is an enumeration.  It is defined with 'False'
--- first so that the corresponding 'Prelude.Enum' instance will give
--- 'Prelude.fromEnum' 'False' the value zero, and
--- 'Prelude.fromEnum' 'True' the value 1.
--- The actual definition is in the ghc-prim package.
-
--- XXX These don't work:
--- deriving instance Eq Bool
--- deriving instance Ord Bool
--- <wired into compiler>:
---     Illegal binding of built-in syntax: con2tag_Bool#
-
-instance Eq Bool where
-    True  == True  = True
-    False == False = True
-    _     == _     = False
-
-instance Ord Bool where
-    compare False True  = LT
-    compare True  False = GT
-    compare _     _     = EQ
-
--- Read is in GHC.Read, Show in GHC.Show
-
 -- |'otherwise' is defined as the value 'True'.  It helps to make
 -- guards more readable.  eg.
 --
index 4409aca..d1c18af 100644 (file)
@@ -44,6 +44,15 @@ class  Eq a  where
     x == y               = not (x /= y)
 
 -- XXX This doesn't work:
+-- deriving instance Eq Bool
+-- <wired into compiler>:
+--     Illegal binding of built-in syntax: con2tag_Bool#
+instance Eq Bool where
+    True  == True  = True
+    False == False = True
+    _     == _     = False
+
+-- XXX This doesn't work:
 -- deriving instance Eq Ordering
 -- Illegal binding of built-in syntax: con2tag_Ordering#
 instance Eq Ordering where
@@ -86,6 +95,15 @@ class  (Eq a) => Ord a  where
     min x y = if x <= y then x else y
 
 -- XXX This doesn't work:
+-- deriving instance Ord Bool
+-- <wired into compiler>:
+--     Illegal binding of built-in syntax: con2tag_Bool#
+instance Ord Bool where
+    compare False True  = LT
+    compare True  False = GT
+    compare _     _     = EQ
+
+-- XXX This doesn't work:
 -- deriving instance Ord Ordering
 -- Illegal binding of built-in syntax: con2tag_Ordering#
 instance Ord Ordering where