From: Ian Lynagh Date: Mon, 23 Nov 2009 20:18:17 +0000 (+0000) Subject: De-orphan the Eq/Ord Bool instances X-Git-Url: http://git.megacz.com/?a=commitdiff_plain;h=ca102a0efb1c88bca67462101403e99e448494bc;p=ghc-base.git De-orphan the Eq/Ord Bool instances --- diff --git a/GHC/Base.lhs b/GHC/Base.lhs index 45ec617..c1db364 100644 --- a/GHC/Base.lhs +++ b/GHC/Base.lhs @@ -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 --- : --- 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. -- diff --git a/GHC/Classes.hs b/GHC/Classes.hs index 4409aca..d1c18af 100644 --- a/GHC/Classes.hs +++ b/GHC/Classes.hs @@ -44,6 +44,15 @@ class Eq a where x == y = not (x /= y) -- XXX This doesn't work: +-- deriving instance Eq Bool +-- : +-- 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 +-- : +-- 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