I have recently found out that in Haskell we can to turn a type constructor into a functor, using the "free functor" construction [1, 2, 3]. I would like to understand this construction – the free object of the $\mathbf{Functor}$ category – in a categorical setting.
I assume that we have two functors going in opposite directions (the free-forgetful pair) between two categories: one modeling type constructors, of kind * → *
; the other modeling functors – type constructors that have more structure (they preserve the functor identity and composition laws). In particular, the "free functor" functor should take a type constructor and turn it into a functor.
Here are some questions that I have:
- What are the categories in question? I assume that $\mathbf{Functor}$ can be modeled by $\left[\mathbf{Set}, \mathbf{Set}\right]$, but how is the category of type constructors defined and what are its morphisms?
- The "free functor" construction is given by the following definition
data CoYoneda f a = forall b. CoYo (f b) (b -> a)
. How can I understand this definition in categorical terms? - The "free functor" is missing from the list of free objects on Wikipedia and I was not able to find out much information on it outside the programming languages community. Is this notion limited to type theory? If so, why?