Relation between covariant representable functor and the slice category functor

The covariant representable functor $\hom (X,-): \sf C \to Sets$ takes objects $A$ to $\hom(X, A)$ and morphisms $f:A \to B$ to post-composition. This looks kind of similar to the slice category functor taking objects to $\textsf{C} /A$ the slice catgory, and morphisms $f:A \to B$ to post-composition (again).

I'm wondering if there is a "neat" (natural?) way to link these two constructions in some way.


The Grothendieck construction converts functors to categories (actually split opfibrations). In the particular case of a covariant functor $F\colon\sf C\to Sets$, it defines a category whose objects are pairs $(A,X)$ satisfying $A\in F(X)$, and a morphism $(A,X)\to(B,Y)$ is a morphism $f\colon X\to Y$ such that $Ff(A)=B$. This category has an obvious forgetful functor to $C$ sending $(A,X)$ to $X$, and recovering the morphism $f\colon X\to Y$.

Applying this to a representable functor $\hom (X,-): \sf C \to Sets$ yields the coslice category $\sf X/C$ whose objects are morphisms with domain $X$, whose morphisms are commutative triangles, and that has a codomain functor $\mathrm{cod}\colon\sf X/C\to C$ sending a morphism $X\to Y$ to its codomain $Y$ and a triangle $X\to Y_1\to Y_2$ to the morphism $Y_1\to Y_2$.

Applying it to the representable contravariant functor $\hom(-,X)$ yields the slice category $\sf C/X$ equipped with the domain functor $\mathrm{dom}\colon\sf C/X\to C$.

If you apply this construction to the functor sending $X$ to the slice category $C/X$ and a morphism $f\colon X\to Y$ to post-composition functor $f_\circ\colon C/X\to C/Y$, the result is the category of arrows $C^\to$ whose objects are morphisms, whose morphisms are commutative squares, equipped with a codomain functor taking the bottom arrow of the square (if the object morphisms are written vertically).