return $ App a' b'
subeverywhere trans c (Let (NonRec b bexpr) expr) = do
- bexpr' <- trans (Other:c) bexpr
- expr' <- trans (Other:c) expr
+ bexpr' <- trans (LetBinding:c) bexpr
+ expr' <- trans (LetBody:c) expr
return $ Let (NonRec b bexpr') expr'
subeverywhere trans c (Let (Rec binds) expr) = do
- expr' <- trans (Other:c) expr
+ expr' <- trans (LetBody:c) expr
binds' <- mapM transbind binds
return $ Let (Rec binds') expr'
where
transbind :: (CoreBndr, CoreExpr) -> TransformMonad (CoreBndr, CoreExpr)
transbind (b, e) = do
- e' <- trans (Other:c) e
+ e' <- trans (LetBinding:c) e
return (b, e')
subeverywhere trans c (Lam x expr) = do
| AppSecond -- ^ The expression is the second
-- argument of an application
-- (i.e., something is applied to it)
+ | LetBinding -- ^ The expression is bound in a
+ -- (recursive or non-recursive) let
+ -- expression.
+ | LetBody -- ^ The expression is the body of a
+ -- let expression
| Other -- ^ Another context
-- | Transforms a CoreExpr and keeps track if it has changed.