[commit: ghc] master: Make Derived NomEq rewrite only Derived NomEq (b626cb0)

git at git.haskell.org git at git.haskell.org
Fri May 1 08:41:46 UTC 2015


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

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

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

commit b626cb08b6b97965eec1ab63a890f8cbcfbcaa5b
Author: Simon Peyton Jones <simonpj at microsoft.com>
Date:   Fri May 1 09:42:21 2015 +0100

    Make Derived NomEq rewrite only Derived NomEq
    
    See Note [Deriveds do rewrite Deriveds].  The important point
    is that we want to maintain the Note [Can-rewrite relation]
    property, lest we risk loops.


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

b626cb08b6b97965eec1ab63a890f8cbcfbcaa5b
 compiler/typecheck/TcFlatten.hs | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/compiler/typecheck/TcFlatten.hs b/compiler/typecheck/TcFlatten.hs
index 65d260b..4c74ba9 100644
--- a/compiler/typecheck/TcFlatten.hs
+++ b/compiler/typecheck/TcFlatten.hs
@@ -1528,7 +1528,7 @@ eqCanRewriteFR :: CtFlavourRole -> CtFlavourRole -> Bool
 -- See Note [Deriveds do rewrite Deriveds]
 eqCanRewriteFR (Given,   NomEq)   (_,       _)      = True
 eqCanRewriteFR (Given,   ReprEq)  (_,       ReprEq) = True
-eqCanRewriteFR (Derived, NomEq)   (Derived, _)      = True
+eqCanRewriteFR (Derived, NomEq)   (Derived, NomEq)  = True
 eqCanRewriteFR _                 _                  = False
 
 canRewriteOrSame :: CtEvidence -> CtEvidence -> Bool
@@ -1566,6 +1566,16 @@ Note [Deriveds do rewrite Deriveds]
 However we DO allow Deriveds to rewrite Deriveds, because that's how
 improvement works; see Note [The improvement story] in TcInteract.
 
+However, for now at least I'm only letting (Derived,NomEq) rewrite
+(Derived,NomEq) and not doing anything for ReprEq.  If we have
+    eqCanRewriteFR (Derived, NomEq) (Derived, _)  = True
+then we lose the property of Note [Can-rewrite relation]
+  R2.  If f1 >= f, and f2 >= f,
+       then either f1 >= f2 or f2 >= f1
+Consider f1 = (Given, ReprEq)
+         f2 = (Derived, NomEq)
+          f = (Derived, ReprEq)
+
 Note [canRewriteOrSame]
 ~~~~~~~~~~~~~~~~~~~~~~~
 canRewriteOrSame is similar but



More information about the ghc-commits mailing list