Is Milner let polymorphism a rank 2 feature?

后端 未结 5 1226
难免孤独
难免孤独 2021-01-31 04:25

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

5条回答
  •  情话喂你
    2021-01-31 04:55

    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.

提交回复
热议问题