[commit: ghc] wip/rae-new-coercible: Pass test for #8984 by treating representational equality differently. (59bba57)

git at git.haskell.org git at git.haskell.org
Mon Dec 8 17:12:40 UTC 2014


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

On branch  : wip/rae-new-coercible
Link       : http://ghc.haskell.org/trac/ghc/changeset/59bba579a2760adf70ca2f4fdc5619a2dc43ba12/ghc

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

commit 59bba579a2760adf70ca2f4fdc5619a2dc43ba12
Author: Richard Eisenberg <eir at cis.upenn.edu>
Date:   Mon Dec 8 11:10:23 2014 -0500

    Pass test for #8984 by treating representational equality differently.


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

59bba579a2760adf70ca2f4fdc5619a2dc43ba12
 compiler/typecheck/TcDeriv.hs    |  1 -
 compiler/typecheck/TcValidity.hs | 14 +++++++++-----
 2 files changed, 9 insertions(+), 6 deletions(-)

diff --git a/compiler/typecheck/TcDeriv.hs b/compiler/typecheck/TcDeriv.hs
index d52a721..b0eed2a 100644
--- a/compiler/typecheck/TcDeriv.hs
+++ b/compiler/typecheck/TcDeriv.hs
@@ -1807,7 +1807,6 @@ inferInstanceContexts infer_specs
         do { theta <- simplifyDeriv the_pred tyvars deriv_rhs
                 -- checkValidInstance tyvars theta clas inst_tys
                 -- Not necessary; see Note [Exotic derived instance contexts]
-                --                in TcSimplify
 
            ; traceTc "TcDeriv" (ppr deriv_rhs $$ ppr theta)
                 -- Claim: the result instance declaration is guaranteed valid
diff --git a/compiler/typecheck/TcValidity.hs b/compiler/typecheck/TcValidity.hs
index bc43ad8..de566ea 100644
--- a/compiler/typecheck/TcValidity.hs
+++ b/compiler/typecheck/TcValidity.hs
@@ -876,12 +876,16 @@ not converge.  See Trac #5287.
 validDerivPred :: TyVarSet -> PredType -> Bool
 validDerivPred tv_set pred
   = case classifyPredType pred of
-       ClassPred _ tys -> hasNoDups fvs
-                       && sizeTypes tys == length fvs
-                       && all (`elemVarSet` tv_set) fvs
-       TuplePred ps -> all (validDerivPred tv_set) ps
-       _            -> True   -- Non-class predicates are ok
+       ClassPred _ tys       -> check_tys tys
+                  -- EqPred ReprEq is a Coercible constraint; treat
+                  -- like a class
+       EqPred ReprEq ty1 ty2 -> check_tys [ty1, ty2]
+       TuplePred ps          -> all (validDerivPred tv_set) ps
+       _                     -> True   -- Non-class predicates are ok
   where
+    check_tys tys = hasNoDups fvs
+                    && sizeTypes tys == length fvs
+                    && all (`elemVarSet` tv_set) fvs
     fvs = fvType pred
 
 {-



More information about the ghc-commits mailing list