Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Oracle 10g Database Administrator Implementation And Administration

Authors: Gavin Powell, Carol McCullough Dieter

2nd Edition

1418836656, 9781418836658

More Books

Students also viewed these Databases questions

Question

Help me analyze the 13C-NMR and 1H-NMR for the unknown compound

Answered: 1 week ago

Question

clarify the relationship between research, theory and practice;

Answered: 1 week ago

Question

2. Discuss the steps in preparing a manager to go overseas.

Answered: 1 week ago

Question

8. Measure the effectiveness of the succession planning process.

Answered: 1 week ago