From 9c05ec8933459aed098ed65f929f748107f5b8b8 Mon Sep 17 00:00:00 2001 From: Ian Lynagh Date: Sat, 12 Apr 2008 10:07:41 +0000 Subject: [PATCH] Ordering has now moved to ghc-prim --- GHC/Base.lhs | 19 ++++++++++++++++++- GHC/Num.lhs | 7 +------ 2 files changed, 19 insertions(+), 7 deletions(-) diff --git a/GHC/Base.lhs b/GHC/Base.lhs index 751a908..5d95a04 100644 --- a/GHC/Base.lhs +++ b/GHC/Base.lhs @@ -86,6 +86,7 @@ module GHC.Base module GHC.Base, module GHC.Bool, module GHC.Generics, + module GHC.Ordering, module GHC.Prim, -- Re-export GHC.Prim and GHC.Err, to avoid lots module GHC.Err -- of people having to import it explicitly ) @@ -93,6 +94,7 @@ module GHC.Base import GHC.Bool import GHC.Generics +import GHC.Ordering import GHC.Prim import {-# SOURCE #-} GHC.Err @@ -561,8 +563,23 @@ instance Ord () where -- | Represents an ordering relationship between two values: less -- than, equal to, or greater than. An 'Ordering' is returned by -- 'compare'. -data Ordering = LT | EQ | GT deriving (Eq, Ord) +-- 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} diff --git a/GHC/Num.lhs b/GHC/Num.lhs index 5f3f865..aed62eb 100644 --- a/GHC/Num.lhs +++ b/GHC/Num.lhs @@ -134,12 +134,7 @@ instance Ord Integer where (>) = gtInteger (<) = ltInteger (>=) = geInteger - - i `compare` j = case i `compareInteger` j of - -1# -> LT - 0# -> EQ - 1# -> GT - _ -> error "compareInteger: Bad result" + compare = compareInteger \end{code} -- 1.7.10.4