プログラミング言語 Standard ML 入門 (問題の解答例)
3 MLの型システム

3.4 関数名の多重定義

問 3.11

以下の各式の型を推定せよ.

  1. 1.

    fn x => x > 1

  2. 2.

    fn x => fn y => fn z => (x y,x "Ada",y > z)

  3. 3.

    fn x => fn y => y (x > x)

解答例  SML#での推論例を示す.

   # fn x => x > 1;
   val it = fn : int  -> bool
   # fn x => fn y => fn z => (x y,x "Ada",y > z);
   val it = fn : [’a .(string  -> ’a)  -> string  -> string  -> ’a * ’a * bool]
   # fn x => fn y => y (x > x);
   val it = fn : int  -> [’a .(bool  -> ’a)  -> ’a]