The Yoneda Lemma

Prev: Representable Functors Next: Yoneda Embedding

Prev: Representable Functors Next: Yoneda Embedding

Exercises

  1. Show that the two functions phi and psi that form the Yoneda isomorphism in Haskell are inverses of each other.
phi :: (forall x . (a -> x) -> F x) -> F a
phi alpha = alpha id
 
psi :: F a -> (forall x . (a -> x) -> F x)
psi fa h = fmap h fa
  1. A discrete category is one that has objects but no morphisms other than identity morphisms. How does the Yoneda lemma work for functors from such a category?
  2. A list of units [()] contains no other information but its length. So, as a data type, it can be considered an encoding of integers. An empty list encodes zero, a singleton [()] (a value, not a type) encodes one, and so on. Construct another representation of this data type using the Yoneda lemma for the list functor.