let多相
パラメトリック多相を少し制限したもの
letで束縛されている変数に限り多相性の伝搬を許す
OCamlのlet .. inを想像するとわかりやすい
A Theory of Type Polymorphism in Programmingが起源?
以下のようなコードに対してidに多相性がないと型エラーになる
code:ml
let id = fun x -> x in if id true then 1 else id 2
なぜなら一度目のidはInt -> Intだが、二度目はBool -> Boolだから
ここでlet多相を用いることで以下のように展開する
code:ml
let id = fun x -> x in
if (fun x -> x) true then 1 else (fun x -> x) 2
こうすることで別もののidを使っていると見なして、letの範囲でのみ適当な型を与えられる
/mrsekut-book-4781912850/155
https://blog.kokuyouwind.com/archives/155/
https://blog.waft.me/2017/10/03/let-polymorphism/
https://eagletmt.hatenadiary.org/entry/20100716/1279288236
http://athos.hatenablog.com/entry/20130223/let_polymorphism_and_restrictions
https://togetter.com/li/82350
https://fetburner.hatenablog.com/entry/2020/06/02/030812
value restriction
https://eagletmt.hatenadiary.org/entry/20100716/1279288236
https://en.wikipedia.org/wiki/Value_restriction
/herp-technote/value restriction
http://jssst.or.jp/files/user/taikai/2018/PPL/ppl1-4.pdf