Repository : ssh://darcs.haskell.org//srv/darcs/ghc

On branch  : master

http://hackage.haskell.org/trac/ghc/changeset/b442ad94c75aa6f8ad89041cb4fb1e16265b1e45

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

commit b442ad94c75aa6f8ad89041cb4fb1e16265b1e45
Author: Simon Peyton Jones <simo...@microsoft.com>
Date:   Thu Oct 4 17:53:07 2012 +0100

    Do not create extra evidence given/derived variables in the Refl case of 
rewriteCtFlavor
    
    Previously this optimisation only applied in the Wanted case,
    but it works perfectly well in the others too, and saves
    redundant evidence bindings.

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

 compiler/typecheck/TcSMonad.lhs |   28 ++++++++++++++--------------
 1 files changed, 14 insertions(+), 14 deletions(-)

diff --git a/compiler/typecheck/TcSMonad.lhs b/compiler/typecheck/TcSMonad.lhs
index 63c475d..ba1a2cb 100644
--- a/compiler/typecheck/TcSMonad.lhs
+++ b/compiler/typecheck/TcSMonad.lhs
@@ -1600,28 +1600,28 @@ Main purpose: create new evidence for new_pred;
 -- NB: this allows us to sneak away with ``error'' thunks for 
 -- coercions that come from derived ids (which don't exist!) 
 
-rewriteCtFlavor (CtDerived {}) pty_new _co
-  = newDerived pty_new
         
-rewriteCtFlavor (CtGiven { ctev_evtm = old_tm }) pty_new co
-  = do { new_ev <- newGivenEvVar pty_new new_tm  -- See Note [Bind new Givens 
immediately]
-       ; return (Just new_ev) }
-  where
-    new_tm = mkEvCast old_tm (mkTcSymCo co)  -- mkEvCast optimises ReflCo
-  
-rewriteCtFlavor ctev@(CtWanted { ctev_evar = evar, ctev_pred = old_pred }) 
-                      new_pred co
+rewriteCtFlavor old_ev new_pred co
   | isTcReflCo co -- If just reflexivity then you may re-use the same variable
-  = return (Just (if old_pred `eqType` new_pred
-                  then ctev 
-                  else ctev { ctev_pred = new_pred }))
+  = return (Just (if ctEvPred old_ev `eqType` new_pred
+                  then old_ev
+                  else old_ev { ctev_pred = new_pred }))
        -- Even if the coercion is Refl, it might reflect the result of 
unification alpha := ty
        -- so old_pred and new_pred might not *look* the same, and it's vital 
to proceed from
        -- now on using new_pred.
        -- However, if they *do* look the same, we'd prefer to stick with 
old_pred
        -- then retain the old type, so that error messages come out mentioning 
synonyms
 
-  | otherwise
+rewriteCtFlavor (CtDerived {}) new_pred _co
+  = newDerived new_pred
+        
+rewriteCtFlavor (CtGiven { ctev_evtm = old_tm }) new_pred co
+  = do { new_ev <- newGivenEvVar new_pred new_tm  -- See Note [Bind new Givens 
immediately]
+       ; return (Just new_ev) }
+  where
+    new_tm = mkEvCast old_tm (mkTcSymCo co)  -- mkEvCast optimises ReflCo
+  
+rewriteCtFlavor (CtWanted { ctev_evar = evar, ctev_pred = old_pred }) new_pred 
co
   = do { new_evar <- newWantedEvVar new_pred
        ; setEvBind evar (mkEvCast (getEvTerm new_evar) co)
        ; case new_evar of



_______________________________________________
Cvs-ghc mailing list
Cvs-ghc@haskell.org
http://www.haskell.org/mailman/listinfo/cvs-ghc

Reply via email to