# Definition

Given two categories, $\mathcal{C}$ and $\mathcal{D}$, a functor, $F$, between these are a function that for objects maps
$$
X \in \mathcal{C} : F(X) \in \mathcal{D}
$$
And for any two arrows $f : X \rightarrow Y$, $g : Y \rightarrow Z$ in $\mathcal{C}$ it maps the composite as thus
$$
F(g \circ f) = F(g) \circ F(f)
$$
Furthermore the $id$ of $\mathcal{C}$ is mapped to into the $id$ of $\mathcal{D}$:
$$
F(id_X) = id_{F(X)}
$$
A functor is essentially a homomorphism between two suitable structures.

### Example - The forgetful functor

Given a structure of some kind the forgetful functor maps this structure to the underlying set. For example given the category of all groups the forgetful functor maps each group to its underlying set
$$
Grp \rightarrow Set
$$
For $G = (\mathbb{Z},+)$ we just have the set $\mathbb{Z}$ after treatment with the forgetful functor. This functor is defined on any mathematical structure. Like $Top \rightarrow Set$ for topological spaces. Or $Mon \rightarrow Set$ for monoids.

### Example - The category of functors

Let $Cat$ be the category of all categories. To not end up in a situation like Russel's paradox, we say that $Cat$ is a big category with small categories (those of arrows and sets) as objects. $Cat$ has functors as arrows.

### Example - Unique functor from any category to 1

Given any category there is a unique functor $\mathcal{C} \rightarrow 1$. In terms of $Cat$ $1$ is called a *terminal object*. That is an object that has an arrow into it for every object in that category.

### Example - Unique functor from 0 to any category

Given any category there is a unique functor $0 \rightarrow \mathcal{C}$. In terms of $Cat$ $0$ is called an *initial object*. That is an object that has an arrow into every object of the given category.

### Example - Lists with map

In any functional programming language like Haskell we have a List type. Lists always have a function associated with them called $map$. Map is a functor. We can define it as follows

map f [] = []
map f (head : tail) f = (map f head) : (map f tail)
map f [s] = [f s]
Which corresponds to the definition of a functor. Lists can be seen as monoids. That is we have the empty list as identity element. Hence $map$ can be seen as a monoid homomorphism between two lists. As mentioned earlier there is a correspondence between monoids and categories.

### Example - Functor between Monoid categories

Let $M$ and $N$ be two monoids as categories with one object and the elements of the underlying sets as arrows. Now a functor $F : M \rightarrow N$ is just the same as a monoid homomorphism.

### Example - Functor between Preorders

Let $P$ and $Q$ be preorders as categories. Now a functor $F : P \rightarrow Q$ is any monotone function. That is it preserves the order.