let a = b in c
can be thought as a syntactic sugar for (\\a -> c) b
, but in a typed setting in general it\'s not the case. For example, in the Milne
Types are not preserved under beta-expansion in any calculus that can express the concept of "dead code". You can probably figure out how to write something similar to this in any usable language:
if True then something typable else utter nonsense
For example, let M = (\x y -> x) (something typable)
and N = (utter nonsense)
and P = (something typable)
, so that M N = P
, and P
is typable, but M N
isn't.
...rereading your question, I see that you only demand that M
be typable, but that seems like a very strange meaning to give to "preserved under beta-expansion" to me. Anyway, I don't see why some argument like the above couldn't apply: simply let M
have some untypable dead code in it.