Functors

Prev: Simple Algebraic Data Types Next: Functoriality

Prev: Simple Algebraic Data Types Next: Functoriality

Exercises

  1. Can we turn the Maybe type constructor into a functor by defining:
fmap _ _ = Nothing

which ignores both of its arguments? (Hint: Check the functor laws.)

  1. Prove functor laws for the reader functor. Hint: it’s really simple.
  2. Implement the reader functor in your second favorite language (the first being Haskell, of course).
  3. Prove the functor laws for the list functor. Assume that the laws are true for the tail part of the list you’re applying it to (in other words, use induction).