Question: (int, float, bool, string) (a) Consider a function with polymorphic type f : a -> a -> a. What is the type of f 0
(int, float, bool, string)
(a) Consider a function with polymorphic type f : a -> a -> a.
What is the type of f 0 ?
What is the type of fun x -> (f f) x ? Briefly explain your reasoning.
(b) Consider a function with polymorphic type f : (a * b) -> (b -> a) -> a
What is the type of f (0, true) ?
What is the type of fun x y -> f (x, y) ? Does it have the same type as f ? Briefly explain your reasoning.
(c) Consider a function with polymorphic type g : (a -> b > b) -> b -> a.
What is the type of g (+)?
What is the type of fun x -> (g g) x ? Briefly explain your reasoning.
(d) Consider the following function.

Is it well typed? Briefly explain your reasoning.
let f (x : int list) : bool list match x with | [] -> x | hd :: tl -> true :: [] let f (x : int list) : bool list match x with | [] -> x | hd :: tl -> true :: []
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
