In category theory, hom-sets, are sets of morphisms between objects. Given objects and in a locally small category, the hom-set is the set of all morphisms from A to B.
\begin{xy} \xymatrix{ A \[email protected]/^/[r] \[email protected]/^1pc/[r] \ar[r] \[email protected]/_/[r] \[email protected]/_1pc/[r] & B } \end{xy}Hom-sets itself give rise to another category where hom-sets are objects and arrows between hom-sets are hom-set morphisms. A hom-set morphism is defined as:
, for
, for
such that the following diagram commutes:
\begin{xy} \[email protected][email protected]!R=1.0cm{ \text{Hom}(A,B) \ar[dr]|-{\text{Hom}(h,f)} \ar[d]_{\text{Hom}(A,f)} \ar[r]^{\text{Hom}(h,B)} & \text{Hom}(C,B) \ar[d]^{Hom(C,f)} \\ \text{Hom}(A,D) \ar[r]_{\text{Hom}(h,D)} & \text{Hom}(C,D) } \end{xy}This can be translated to Hask, the category with Haskell types as objects and functions as morphisms. The previous morphisms are now functions:
f :: b -> d
, h :: c -> a
and b, such that:
Let’s have a closer look at the morphism from to . So we have a and a morphisms that tells us we can go resulting in . Now, this makes sense if we remember how function composition works:
\begin{xy} \xymatrix { c \ar[r]^{f'} \ar[dr]_{g' \circ {f'}} & a \ar[d]^{g'} & \\ & b &&&&& } \end{xy}We can see that is the function composition . Thus, a hom-set morphism is simply morphism pre-composition and is just morphism post-composition . Furthermore, , which you can think of as , is called a covariant hom-functor or representable functor from the category to the category , with and . When the second position is fixed (which you can think of as: ) then it’s called a contravariant functor. Consequently, if non of the arguments of the hom-functor are fixed then we have a hom bifunctor also called profunctor, see for instance the diagonal arrow with pre- and post-composition.