Why does a partial application have value restriction?

后端 未结 4 1905
日久生厌
日久生厌 2021-01-24 02:15

I can understand that allowing mutable is the reason for value restriction and weakly polymorphism. Basically a mutable ref inside a function may change the type in

4条回答
  •  情话喂你
    2021-01-24 02:44

    The value restriction is pretty simple: only let-bound expressions that are syntactically values are generalized. Applications, including partial applications, are not values and thus are not generalized.

    Note that in general it is impossible to tell whether an application is partial, and thus whether the application could have an effect on the value of a reference cell. Of course in this particular case it is obvious that no such thing occurs, but the inference rules are designed to be sound in the event that it does.

提交回复
热议问题