[commit: ghc] wip/nomeata-T2110: In simpleOptExpr, unfold compulsary unfoldings (dc6ccbd)

git at git.haskell.org git at git.haskell.org
Mon Jan 27 13:05:49 UTC 2014


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

On branch  : wip/nomeata-T2110
Link       : http://ghc.haskell.org/trac/ghc/changeset/dc6ccbd1f436d9094d2e0496d1232fc82db20925/ghc

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

commit dc6ccbd1f436d9094d2e0496d1232fc82db20925
Author: Joachim Breitner <mail at joachim-breitner.de>
Date:   Fri Jan 24 13:35:21 2014 +0000

    In simpleOptExpr, unfold compulsary unfoldings
    
    such as that of coerce.


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

dc6ccbd1f436d9094d2e0496d1232fc82db20925
 compiler/coreSyn/CoreSubst.lhs |   12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/compiler/coreSyn/CoreSubst.lhs b/compiler/coreSyn/CoreSubst.lhs
index 3dedbc8..8ea645b 100644
--- a/compiler/coreSyn/CoreSubst.lhs
+++ b/compiler/coreSyn/CoreSubst.lhs
@@ -966,6 +966,10 @@ simple_app subst (Lam b e) (a:as)
   where
     (subst', b') = subst_opt_bndr subst b
     b2 = add_info subst' b b'
+simple_app subst (Var v) as
+  | isCompulsoryUnfolding (idUnfolding v)
+  -- See Note [Unfold compulsory unfoldings in LHSs]
+  =  simple_app subst (unfoldingTemplate (idUnfolding v)) as
 simple_app subst e as
   = foldl App (simple_opt_expr subst e) as
 
@@ -1112,6 +1116,14 @@ we don't know what phase we're in.  Here's an example
 When inlining 'foo' in 'bar' we want the let-binding for 'inner' 
 to remain visible until Phase 1
 
+Note [Unfold compulsory unfoldings in LHSs]
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+When the user writes `map coerce = coerce` as a rule, the rule will only ever
+match if we replace coerce by its unfolding on the LHS, because that is the
+core that the rule matching engine will find. So do that for everything that
+has a compulsory unfolding. Also see Notes [Desugaring coerce as cast] and
+[The shape of coerce].
 
 %************************************************************************
 %*                                                                      *



More information about the ghc-commits mailing list