1. Implement Functor instances for Either e and ((->) e).

Solution for Either e:

Proof:

To prove implementation is correct, we need to prove the following.

Solution for ((->) e).

Proof:

  1. Implement Functor instances for ((,) e) and for Pair, defined as

Solution for ((,) e):

Proof:

Solution for Pair:

Proof:

Explain their similarities and differences.

  1. Implement a Functor instance for the type ITree, defined as

Solution:

Proof:

The second to last equality can by proven by structural induction.

  1. Give an example of a type of kind * -> * which cannot be made an instance of Functor (without using undefined).

Draft:

  1. Is this statement true or false?

The composition of two Functors is also a Functor.

If false, give a counterexample; if true, prove it by exhibiting some appropriate Haskell code.

Draft:

Proof: