[commit: ghc] master: Teach optCoecion about FunCo (783dfa7)

git at git.haskell.org git at git.haskell.org
Thu May 4 13:35:01 UTC 2017


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

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

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

commit 783dfa744b14e682951a8358e51356a2dedda325
Author: Simon Peyton Jones <simonpj at microsoft.com>
Date:   Tue May 2 16:30:38 2017 +0100

    Teach optCoecion about FunCo
    
    I was seeing coercions like
    
       Nth 3 ((c2 -> c2) ; (c3 -> c4))
    
    which made me realise that optCoercion was doing a bad job
    of the (relatively new) FunCo.
    
    In particular, opt_trans_rule needs a FunCo/FunCo case,
    to go with the TyConAppCo/TyConAppCo case.  Easy.
    
    No behavioural change, some coercions will get smaller


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

783dfa744b14e682951a8358e51356a2dedda325
 compiler/types/OptCoercion.hs | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/compiler/types/OptCoercion.hs b/compiler/types/OptCoercion.hs
index 7f96754..b1aa646 100644
--- a/compiler/types/OptCoercion.hs
+++ b/compiler/types/OptCoercion.hs
@@ -555,6 +555,11 @@ opt_trans_rule is in_co1@(TyConAppCo r1 tc1 cos1) in_co2@(TyConAppCo r2 tc2 cos2
     fireTransRule "PushTyConApp" in_co1 in_co2 $
     mkTyConAppCo r1 tc1 (opt_transList is cos1 cos2)
 
+opt_trans_rule is in_co1@(FunCo r1 co1a co1b) in_co2@(FunCo r2 co2a co2b)
+  = ASSERT( r1 == r2 )   -- Just like the TyConAppCo/TyConAppCo case
+    fireTransRule "PushFun" in_co1 in_co2 $
+    mkFunCo r1 (opt_trans is co1a co2a) (opt_trans is co1b co2b)
+
 opt_trans_rule is in_co1@(AppCo co1a co1b) in_co2@(AppCo co2a co2b)
   = fireTransRule "TrPushApp" in_co1 in_co2 $
     mkAppCo (opt_trans is co1a co2a)



More information about the ghc-commits mailing list