Functor

  • a functor is a mapping between categories, F โˆถ ๐’ž โ†’ ๐’Ÿ

  • an identity functor maps a category back to itself, F โˆถ ๐’ž โ†’ ๐’ž

  • a functor does the mapping by using 2 morphisms:

    • Fโ‚’ : a -> F a for mapping objects to objects

    • Fโ‚˜ : f -> F f for mapping arrows to arrows

Functors are one of the fundamental elements of category theory. Functors allow for translation between different branches of mathematics and they play an important role in FP where they, among other things, facilitate defining container types, or, more generally, type constructors.

A functor (also called "morphism of categories") is a mapping between categories, F โˆถ ๐’ž โ†’ ๐’Ÿ : not only it maps objects in ๐’ž to objects in ๐’Ÿ, but it also maps morphisms in ๐’ž to morphisms in ๐’Ÿ.

The identity functor maps a category, ๐’ž, back to itself, Fษชแด… : ๐’ž โ†’ ๐’ž by mapping each object in ๐’ž to itself, and each arrow in ๐’ž to itself.

A functor F maps between categories ๐’ž and ๐’Ÿ using its two component morphisms, one for mapping objects and the other for mapping arrows:

  • component morphism Fโ‚’ that maps each object a in ๐’ž to an object F a in ๐’Ÿ with signature Fโ‚’ : a โ†’ F a

  • component morphism Fโ‚˜ that assigns to each arrow f : a โ†’ b in ๐’ž, an arrow F f : F a โ†’ F b in ๐’Ÿ such that F (g โ—ฆ f) = F g โ—ฆ F f and F 1แด€ = 1๊œฐโ‚

===============================================================================

Definition Let `๐’ž` and `๐’Ÿ` be categories. A functor `F โˆถ ๐’ž โ†’ ๐’Ÿ` (consisting of two "subfunctors", `Fโ‚’` for maping obj, and `Fโ‚˜` for arrows) assigns to each object `a` in `๐’ž` an object `Fโ‚’ a` in `๐’Ÿ`, and to each morphism `f โˆถ a โ†’ b` in `๐’ž` a morphism `Fโ‚˜ f โˆถ Fโ‚’ a โ†’ Fโ‚’ b` in `๐’Ÿ`, such that, for all objects `a` in `๐’ž`, `Fโ‚’ (idแด€) = id๊œฐแด€`, and, for all morphisms `f โˆถ a โ†’ b` and `g โˆถ b โ†’ c` in `๐’ž`, `Fโ‚˜ (g โˆ˜ f) = Fโ‚˜ (g) โˆ˜ Fโ‚˜ (f)`.

===============================================================================

Functors are composable which allows us to define the category of (small) categories, ๐—–๐—ฎ๐˜, where objects are categories, morphisms are functors, and identity arrows are identity functors.

[FAQ] Objects in a category are connected by arrows, and object across categories are connected by functors. However, an identity functor maps objects to themselves in a category, meaning objects can be mapped by arrows and functors (just saying).

A functor from a category to itself is called an endofunctor.

An example of functors is the power set operation, which yields an endofunctor in Set.

Last updated