Question: Type inference systems a) Consider the following function in Haskell: f x = if x == x then True else (f False) or equivalently: f
Type inference systems
a) Consider the following function in Haskell:
f x = if x == x then True else (f False) or equivalently:
f = \x -> if x == x then True else (f False)
What type does this function have in Haskell?
b) What is the most general type it could have?
c) Show how Haskell calculates the type of f. Explain why the Haskell type is not as general as it could be (i.e., explain why the type inferencer gives a more specialized type than necessary). Note that because f is a recursive function, to calculate the type of f, we need the additional rule to those given in class that the type of f to the left of = is the same as the occurrence in the function body on the right.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
