proc (int x) x let f = proc (int x) x in (f 10) let f = proc (int x) x g = proc ((int -> int) y) y in (g f) let f = proc (bool x) x g = proc ((bool -> bool) y) (y false) in (g f) let f = proc (bool x, int z) x g = proc ((bool*int -> bool) y) (y false 10) in (g f) let f = proc (bool x) proc(int z) x g = proc ((bool -> (int -> bool)) y) ((y false) 10) in (g f) letrec bool f (bool x) = x in (f false) letrec int f (bool x) = (f x) in (f false) letrec int f (bool x, int w) = (f x w) in (f false 12) // At least 5 ill-typed expressions. ( proc (int x) x true ) let f = 3 in (f 3) letrec bool f () = 2 in (f) letrec bool f () = true in +((f), 2) +(2,true) if 2 then true else true if true then 1 else true let x = 3 in set x = false // Good expressions with pairs pair(true, 2) fst(pair(true, 2)) snd(pair(true,2)) let x = 3 in pair(x,x) let y = pair(1,1) in fst(y) let swap = proc( (int*bool) x ) pair (snd(x), fst(x)) in (swap pair (1,true)) // ill-typed expressions with pairs let f = proc ((int*bool) x) x in (f pair(2,2)) let f = proc (int x) fst(x) in (f 2) let x = 2 in snd(x) // Well-typed exps with lists []:list(int) cons(1,cons(2,cons(3, [] : list(int)))) hd(cons(1,[]:list(int))) letrec list(int) imap(list(int) x, (int -> int) f) = if null?(x) then []:list(int) else cons ( (f hd(x)), tl(x) ) in (imap cons(1, cons(2, cons(3, []:list(int)))) proc (int x) +(x,1)) // Ill-typed exps with lists cons(true, []:list(int)) let x = []:list(int) in if hd(x) then 1 else 2 let x = []:list(int) in cons(tl(x), 2)