-Note [exprArity invariant]
-~~~~~~~~~~~~~~~~~~~~~~~~~~
-exprArity has the following invariant:
-
- * If typeArity (exprType e) = n,
- then manifestArity (etaExpand e n) = n
-
- That is, etaExpand can always expand as much as typeArity says
- So the case analysis in etaExpand and in typeArity must match
-
- * exprArity e <= typeArity (exprType e)
-
- * Hence if (exprArity e) = n, then manifestArity (etaExpand e n) = n
-
- That is, if exprArity says "the arity is n" then etaExpand really
- can get "n" manifest lambdas to the top.
-
-Why is this important? Because
- - In TidyPgm we use exprArity to fix the *final arity* of
- each top-level Id, and in
- - In CorePrep we use etaExpand on each rhs, so that the visible lambdas
- actually match that arity, which in turn means
- that the StgRhs has the right number of lambdas
-
-An alternative would be to do the eta-expansion in TidyPgm, at least
-for top-level bindings, in which case we would not need the trim_arity
-in exprArity. That is a less local change, so I'm going to leave it for today!
-
-