According to nLab article:
https://ncatlab.org/nlab/show/functor
Definition
External definition
A functor $F$ from a category $C$ to a category $D$ is a map sending each object $x \in C$ to an object $F(x) \in D$ and each morphism $f : x \to y$ in $C$ to morphism $F(f) : F(x) \to F(y)$ in $D$, such that
$F$ preserves composition: $F(g\circ f) = F(g)\circ F(f)$ whenever the left-hand side is well-defined,
$F$ preserves identity morphisms: for each object $x \in C$, $F(1_x) = 1_{F(x)}$.
So, functor is often called "structure preserving".
However, there is an interesting article:
https://www.schoolofhaskell.com/user/edwardk/snippets/fmap
The free theorem for fmap
When we write down the definition of Functor we carefully state two laws:
fmap id = id
fmap f . fmap g = fmap (f . g)
These are pretty well known in the Haskell community.
What is less well known is that the second actually follows from the first and parametricity, so you only need to sit down and prove one Functor
law when you go to supply a Functor
!
This is a “folklore” result, which I've used in conversation many times before, but it continues to surprise folks, so I decided to write up a slow, step by step proof of this result as it is a fun little exercise in equational reasoning.
To prove this we're going to need the free theorem for fmap
and a few lemmas.
So, my question is does this apply not only to the category of set and function composition but also category theory in general?
Thanks.