The identity function written as a lambda with bee emoji λ 🐝 . 🐝
Go to blog on GitHub
Chapter 3 Exercises
Types and Clauses
Connor Baker 2019-12-21

Exercise 1

What are the types of the following values?

Exercise 2

Write down definitions that have the following types; it does not matter what the definitions do as long as they are type correct.

Exercise 3

What are the types of the following functions?

Exercise 4

Check your answers to the proceeding questions using GHCi.

Omitted.

Exercise 5

Why is it not feasible in general for function types to be instances of the Eq class? When is it feasible? Hint: two functions of the same type are equal if they always return equal results for equal arguments.

Being an instance of the Eq class means that the type is comparable. With integers, comparability is no problem – we are taught the strict total ordering of < on the set of the integers with the number line from an early age. However, to discern whether two functions are equal, one must check whether they define the same mappings. This requires operating on the entirety of the domain of both functions, which is computationally expensive.

One can raise additional questions: