[commit: ghc] master: Add Eq instances for TrName, Module (5dc28ba)

git at git.haskell.org git at git.haskell.org
Tue Feb 28 15:59:23 UTC 2017


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

On branch  : master
Link       : http://ghc.haskell.org/trac/ghc/changeset/5dc28ba5886cd64a864dbda5aa6989bb91838866/ghc

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

commit 5dc28ba5886cd64a864dbda5aa6989bb91838866
Author: Ben Gamari <bgamari.foss at gmail.com>
Date:   Mon Feb 27 17:12:04 2017 -0500

    Add Eq instances for TrName, Module
    
    Test Plan: Validate
    
    Reviewers: austin
    
    Subscribers: thomie
    
    Differential Revision: https://phabricator.haskell.org/D3227


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

5dc28ba5886cd64a864dbda5aa6989bb91838866
 libraries/ghc-prim/GHC/Classes.hs                  | 10 ++++++++++
 testsuite/tests/typecheck/should_fail/T5095.stderr |  2 +-
 2 files changed, 11 insertions(+), 1 deletion(-)

diff --git a/libraries/ghc-prim/GHC/Classes.hs b/libraries/ghc-prim/GHC/Classes.hs
index 3fd4bc0..4479ac0 100644
--- a/libraries/ghc-prim/GHC/Classes.hs
+++ b/libraries/ghc-prim/GHC/Classes.hs
@@ -58,6 +58,7 @@ import GHC.Magic ()
 import GHC.IntWord64
 import GHC.Prim
 import GHC.Tuple
+import GHC.CString (unpackCString#)
 import GHC.Types
 
 #include "MachDeps.h"
@@ -171,6 +172,15 @@ instance (Eq a) => Eq [a] where
     (x:xs) == (y:ys) = x == y && xs == ys
     _xs    == _ys    = False
 
+deriving instance Eq Module
+
+instance Eq TrName where
+    TrNameS a == TrNameS b = isTrue# (a `eqAddr#` b)
+    a == b = toString a == toString b
+      where
+        toString (TrNameS s) = unpackCString# s
+        toString (TrNameD s) = s
+
 deriving instance Eq Bool
 deriving instance Eq Ordering
 
diff --git a/testsuite/tests/typecheck/should_fail/T5095.stderr b/testsuite/tests/typecheck/should_fail/T5095.stderr
index a959811..14d864a 100644
--- a/testsuite/tests/typecheck/should_fail/T5095.stderr
+++ b/testsuite/tests/typecheck/should_fail/T5095.stderr
@@ -7,7 +7,7 @@ T5095.hs:9:9: error:
         instance Eq Integer
           -- Defined in ‘integer-gmp-1.0.0.1:GHC.Integer.Type’
         ...plus 23 others
-        ...plus three instances involving out-of-scope types
+        ...plus five instances involving out-of-scope types
         (use -fprint-potential-instances to see them all)
       (The choice depends on the instantiation of ‘a’
        To pick the first instance above, use IncoherentInstances



More information about the ghc-commits mailing list