eta-expansion

Simon Marlow simonmar@microsoft.com
Wed, 30 Apr 2003 10:11:45 +0100


=20
> | In the same paper is the case-eta-expansion, but I don't understand
> | the correctness of this transformation:
> |=20
> | case e of {p1 -> e1,...,pn -> en}
> | =3D=3D=3D> \y -> case e of {p1 -> e1 y, ..., pn -> en y}
> |=20
> | The rhs is a WHNF, but the lhs isn't, so the rule
> | can't be correct in general. For example, assume that e is bot.
>=20
> Right.  It's only done if 'e' is cheap (a variable, or something like
> that).

Actually, looking at the code, we also do it if 'e' is known to be
bottom: CoreUtils.exprIsCheap returns True for known-divergent
expressions.  Which seems wrong for eta expansion, no?

It's probably the case that if we have 'case _|_ of ...' then the
simplifier will already have turned it into _|_, so it won't crop up.
But it still looks wrong, unless I'm missing something?

Cheers,
	Simon