TITLE: What is the difference between a function and a morphism?
QUESTION [9 upvotes]: Say I have a function $f$. Then, if I understand correctly, $f$ can be regarded as a morphism in a suitably chosen category which has the domain of $f$ and the range of $f$ as objects.
So, the other direction. Say I have a morphism $f$ in some category from one object $A$ to another object $B$. Can I not regard $f$ as a function whose domain is $\{A\}$ and range $\{B\}$?
I'm interested in looking for contexts in which the latter move is not appropriate for some reason.

REPLY [6 votes]: There are various natural categories in topology where morphisms are not functions. For instance, you may define for every $n$ the category whose objects are all compact closed $n$-manifolds and whose morphisms are the $(n+1)$-dimensional cobordisms, i.e. compact $(n+1)$-manifolds $W$ with boundary, where each boundary component of $W$ is coloured with a "+" or "-" sign. Of course you cannot interprete a cobordism $W$ from two $n$-manifolds $M$ and $N$ as a function $M\to N$. However, you can naturally define a "composition" of morphisms by gluing the manifolds. The "identity" is just the product manifold $W = M \times [0,1]$.
You can also construct embedded versions of that. For instance: objects are compact 1-submanifolds of $\mathbb R^2$ (i.e. finitely many disjoint circles) and morphisms are proper subsurfaces of $\mathbb R^2 \times [0,1]$. You might decide to see morphisms only up to isotopy fixing their boundary.

REPLY [5 votes]: Another interesting reason why categories cannot be identified always with categories having functions for morphisms is given in this paper, by Peter Freyd in which is proven that there are some categories which aren't concrete: i.e. which don't have any faithful functor from the category in $\mathbf{Set}$ (the category of sets and functions). Having a such functor is necessary condition to have functions as morphisms.

REPLY [3 votes]: A main point is that considering objects and morphism (more generally than sets with some structure and functions that preserve it), is both a clarifying and fruitful abstraction. There are situations in which a category may be represented by a sub-category of the Set category (though it can be more complicated than what you suggested. If you are interested, you may start from the Yoneda lemma). But, in order to understand universal properties and to make categorical constructions it could even be counter-productive, like e.g. insisting in metrization with topological spaces, or coordinates with vector spaces.