[commit: ghc] master: Remove unnecessary Ord instance for ConLike (2cb5577)

git at git.haskell.org git at git.haskell.org
Mon Mar 21 10:40:36 UTC 2016


Repository : ssh://git@git.haskell.org/ghc

On branch  : master
Link       : http://ghc.haskell.org/trac/ghc/changeset/2cb55772c5359e5d71d34e5d42a4a7deb6a5d3db/ghc

>---------------------------------------------------------------

commit 2cb55772c5359e5d71d34e5d42a4a7deb6a5d3db
Author: Bartosz Nitka <niteria at gmail.com>
Date:   Mon Mar 21 03:34:03 2016 -0700

    Remove unnecessary Ord instance for ConLike
    
    The Ord instance for ConLike uses Unique order which is bad for
    determinism. Fortunately it's not used, so we can just delete it.
    The is part of the effort to make Unique comparisons explicit.
    
    Test Plan: ./validate
    
    Reviewers: austin, simonmar, bgamari, simonpj
    
    Reviewed By: simonpj
    
    Subscribers: thomie
    
    Differential Revision: https://phabricator.haskell.org/D2018
    
    GHC Trac Issues: #4012


>---------------------------------------------------------------

2cb55772c5359e5d71d34e5d42a4a7deb6a5d3db
 compiler/basicTypes/ConLike.hs      | 9 +++------
 compiler/basicTypes/ConLike.hs-boot | 1 -
 compiler/types/TyCoRep.hs           | 2 +-
 3 files changed, 4 insertions(+), 8 deletions(-)

diff --git a/compiler/basicTypes/ConLike.hs b/compiler/basicTypes/ConLike.hs
index c25f822..69d1836 100644
--- a/compiler/basicTypes/ConLike.hs
+++ b/compiler/basicTypes/ConLike.hs
@@ -65,12 +65,9 @@ instance Eq ConLike where
     (==) = (==) `on` getUnique
     (/=) = (/=) `on` getUnique
 
-instance Ord ConLike where
-    (<=) = (<=) `on` getUnique
-    (<) = (<) `on` getUnique
-    (>=) = (>=) `on` getUnique
-    (>) = (>) `on` getUnique
-    compare = compare `on` getUnique
+-- There used to be an Ord ConLike instance here that used Unique for ordering.
+-- It was intentionally removed to prevent determinism problems.
+-- See Note [Unique Determinism] in Unique.
 
 instance Uniquable ConLike where
     getUnique (RealDataCon dc) = getUnique dc
diff --git a/compiler/basicTypes/ConLike.hs-boot b/compiler/basicTypes/ConLike.hs-boot
index 3463287..c915364 100644
--- a/compiler/basicTypes/ConLike.hs-boot
+++ b/compiler/basicTypes/ConLike.hs-boot
@@ -11,7 +11,6 @@ data ConLike = RealDataCon DataCon
 
 instance Eq ConLike
 instance Typeable ConLike
-instance Ord ConLike
 instance NamedThing ConLike
 instance Data ConLike
 instance Outputable ConLike
diff --git a/compiler/types/TyCoRep.hs b/compiler/types/TyCoRep.hs
index fa123a0..6fe1ce3 100644
--- a/compiler/types/TyCoRep.hs
+++ b/compiler/types/TyCoRep.hs
@@ -1456,7 +1456,7 @@ data TyThing
   | AConLike ConLike
   | ATyCon   TyCon       -- TyCons and classes; see Note [ATyCon for classes]
   | ACoAxiom (CoAxiom Branched)
-  deriving (Eq, Ord)
+  deriving (Eq)
 
 instance Outputable TyThing where
   ppr = pprTyThing



More information about the ghc-commits mailing list