I've been reading up on Applicative Functors and I am having difficulty reconciling a mismatch in the respective terminologies of category theory and functional programming.
Although I have looked over various blogs, the most complete resources that I have been using for this research are:
- McBride & Paterson - Applicative Programming with effects (PDF)
- Gibbons & Oliveira - The Essence of the Iterator Pattern (PDF)
- Tomas Petricek - Writing idioms in LINQ
In category theory, a functor is a morphism from a source category to a target category (in a category of categories). The "category of categories" has a collection of objects that contains both the source and target categories and a collection of functors that contains: the source category's identity functor; the target category's identity functor; and, the functor connecting the source to the target (If the source category is the same as the target category and the functor in question is the identity, then there need only be that one functor).
In functional programming, applicative functors are described as a pair of operations:
pure : a -> f a
<*> : f ( a -> b) -> f a -> f b
.
Here's my question
What interpretation makes clear the correspondence between the the functional programming definition of an applicative functor and the category theoretical definition of a functor?
More specifically, what parts of the tuple (pure,<*>)
correspond to:
- the source category
- the target category
- the category where the functor lives
- the functor's structure-preserving effect on the objects of the source category
- the functor's structure-preserving effect on the morphisms of the source category
Notes: I recognize that this may be an incomplete metaphor, and there may not be a one-to-one correspondence for each of the concepts that I mentioned. I have purposely refrained from sharing my speculation about the apparent correspondences here in order to keep my question simple and to avoid confounding the issues further.