rhs' = tidyExpr rec_tidy_env rhs
- -- the CafInfo for a recursive group says whether *any* rhs in
- -- the group may refer indirectly to a CAF (because then, they all do).
- (bndrs, rhss) = unzip prs'
- pred v = v `notElem` bndrs
-
-
tidyTopBinder :: Module -> IdEnv Bool
-> CgInfoEnv
-> TidyEnv -> CoreExpr
ok_note InlineCall = True
ok_note other = False
-- Notice that we do not look through __inline_me__
- -- This one is a bit more surprising, but consider
+ -- This may seem surprising, but consider
-- f = _inline_me (\x -> e)
-- We DO NOT want to eta expand this to
-- f = \x -> (_inline_me (\x -> e)) x
-- would return
-- (/\b. coerce T (\y::A -> (coerce (A->B) (E b) y)
--- (case x of { I# x -> /\ a -> coerce T E)
-
etaExpand n us expr ty
| n == 0 -- Saturated, so nothing to do
= expr
that would leave use with some lets sandwiched between lambdas; that's
what the final test in the first equation is for.
+In Case 1, we may have to sandwich some coerces between the lambdas
+to make the types work. exprEtaExpandArity looks through coerces
+when computing arity; and etaExpand adds the coerces as necessary when
+actually computing the expansion.
+
\begin{code}
tryEtaExpansion :: OutExpr -> OutType -> SimplM ([OutBind], OutExpr)
tryEtaExpansion rhs rhs_ty