summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBen Gamari <bgamari.foss@gmail.com>2017-02-27 17:12:04 -0500
committerBen Gamari <ben@smart-cactus.org>2017-02-28 10:56:06 -0500
commit5dc28ba5886cd64a864dbda5aa6989bb91838866 (patch)
treef5b32d1bcaa96802f10c256266365d2ed9098424
parent1db71f59de37987446487c7c6ee502020d34f42a (diff)
downloadhaskell-5dc28ba5886cd64a864dbda5aa6989bb91838866.tar.gz
Add Eq instances for TrName, Module
Test Plan: Validate Reviewers: austin Subscribers: thomie Differential Revision: https://phabricator.haskell.org/D3227
-rw-r--r--libraries/ghc-prim/GHC/Classes.hs10
-rw-r--r--testsuite/tests/typecheck/should_fail/T5095.stderr2
2 files changed, 11 insertions, 1 deletions
diff --git a/libraries/ghc-prim/GHC/Classes.hs b/libraries/ghc-prim/GHC/Classes.hs
index 3fd4bc06b0..4479ac0120 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 a9598115ac..14d864a592 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