Open conal opened 10 years ago
There isn't, but I think this would work:
{-# LANGUAGE ScopedTypeVariables #-}
progNonRecSubstR :: forall c m. Rewrite c m CoreProg
progNonRecSubstR = do
ProgCons (NonRec v _) _ <- idR
extractR (anybuR (promoteExprR (unfoldPredR (const . (==v))) :: Rewrite c m Core)) >>> progBindElimR
To handle recursive groups at the CoreProg
level, you'd probably want a rewrite that breaks them into non-recursive bindings and SCC recursive groups. I believe GHC's occurAnalysePgm
will do this (along with some other stuff), so you could lift it into a rewrite. Neil lifted the expression-level version in HERMIT.Dictionary.GHC
.
Thanks!
Is there a transformation like
letSubstR
but forCoreProg
instead ofCoreExpr
? Perhaps it would amount to a traversal withunfoldNameR
, plus a transformation to remove unused definitions. I guess it'd have to include a check that the name is not exported.