A category consists of a collection of objects with morphisms between them. A morphism $~$f$~$ goes from one object, say $~$X$~$, to another, say $~$Y$~$, and is drawn as an arrow from $~$X$~$ to $~$Y$~$. Note that $~$X$~$ may equal $~$Y$~$ (in which case $~$f$~$ is referred to as an [-endomorphism]). The object $~$X$~$ is called the source or domain of $~$f$~$ and $~$Y$~$ is called the target or codomain of $~$f$~$, though note that $~$f$~$ itself need not be a Function and $~$X$~$ and $~$Y$~$ need not be sets. This is written as $~$f: X \rightarrow Y$~$.
These morphisms must satisfy three conditions:
- [Composition_of_functions Composition]: For any two morphisms $~$f: X \rightarrow Y$~$ and $~$g: Y \rightarrow Z$~$, there exists a morphism $~$X \rightarrow Z$~$, written as $~$g \circ f$~$ or simply $~$gf$~$.
- Associativity: For any morphisms $~$f: X \rightarrow Y$~$, $~$g: Y \rightarrow Z$~$ and $~$h:Z \rightarrow W$~$ composition is associative, i.e., $~$h(gf) = (hg)f$~$.
- [identity_map Identity]: For any object $~$X$~$, there is a (unique) morphism, $~$1_X : X \rightarrow X$~$ which, when composed with another morphism, leaves it unchanged. I.e., given $~$f:W \rightarrow X$~$ and $~$g:X \rightarrow Y$~$ it holds that: $~$1_X f = f$~$ and $~$g 1_X = g$~$.