Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
次のように定義された foo 関数があります
fun foo f = f 5;
関数の型を推測する方法は?
関数でなければならないことがわかりfます。また、 を呼び出すので、 f が整数を入力として受け取ることもわかりますf 5。したがってf、 type が必要int -> 'aです。
f
f 5
int -> 'a
foo次に を取りint -> 'a、 を生成し'a、yield: を生成しますfoo : (int -> 'a) -> 'a。
foo
'a
foo : (int -> 'a) -> 'a
SML は、このアルゴリズムの変形を使用して型推論を行います。
http://en.wikipedia.org/wiki/Hindley%E2%80%93Milner