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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started