A covariant functor maps objects from one category to another and preserves morphisms in the same direction. If an arrow connects A to B, the mapped objects F(A) and F(B) retain a corresponding arrow from F(A) to F(B). section 7.1
Mapping objects and arrows
Take the objects 0, 1, and 2, with arrows 0→1 and 0→2. The function F maps them to Bob, Bruce, and Eric: F(0) = Bob, F(1) = Bruce, and F(2) = Eric. The original arrows are preserved as Bob→Bruce and Bob→Eric. section 7.1
Figure 7.1 A small category with three objects, represented by the nodes, and six morphisms, represented by the arrows
Use the small category diagram to inspect objects as nodes and morphisms as arrows before following their covariant mapping. section 7.1
The same idea supports several useful distinctions:
- A functor may map between different categories or remain within one category; the latter is a covariant endofunctor. section 7.1
- A contravariant functor preserves morphisms while reversing their direction. section 7.4
- In programming-language type systems, generic interfaces can be understood as covariant or contravariant functors over assignment-compatibility relationships. section 7.4
