haskellfunctional-programmingcategory-theorymonoids

Confused about why all morphisms for a monoid are not the same as the identity morphism


I am busy reading Bartosz Milewski's Category Theory book for programmers and I'm struggling with the depiction of non-identity morphisms when moving between describing a monoid as a set and a monoid as a category.

I understand that when viewing a monoid (eg. a string) in the context of as a set, we are interested in describing various functions that make use of the 'append' characteristic, for example a function that appends "dog" or a function that appends "mmm" to whatever input it receives. These functions will, respectively, map their input to another element within the set of strings. This obviously includes the possibility of appending nothing.

When we view this monoid in the context of as a category, as far as I understand, we are zooming out to a level of abstraction where this monoid object represents the entire 'string' type and we are no longer interested in how elements are mapped to each other within this type, as we have represented this entire type as a singular dot/object.

Following from this, I would assume that at this level of abstraction, all functions that were described in the 'Set' context would look identical, as they all map string -> string. In my mind, this means that in the context of a category, the identity function (appending nothing) would look identical to the AppendDog or AppendMmm functions mentioned earlier, or any other function for that matter.

My reasoning is obviously incorrect though, as looking at this diagram in the book, morphisms that go from the monoid object to itself, are shown as unique entities:

Monoid as a category and set

As a closing statement/summary: I do not understand why we are still interested in depicting functions within a monoid set once we have abstracted it to a category. Once the set becomes an object in a category, where that object represents the entire type, would all functions within that set not all look like identity functions, as from our new vantage point, they all seem to start from that type and return to that type.

I hope I've made my confusion clear. Thanks in advance for any help!


Solution

  • What I believe you are observing is the fact that every monoid is homomorphic to the trivial monoid. If you just look at the dot-and-arrow diagram of any monoid, it is also a valid diagram of the trivial monoid, but this diagram is not the whole picture.

    When you are "abstracting" you are essentially throwing away the equivalence relation on the monoid and supplementing the weakest one possible. Append "mm" and Append "" are different, but the diagram doesn't illustrate that. It's possible to imagine that they are equal and you will get a valid monoid, but that changes the equivalence relation.

    Even if we discard some of the specifics, the fact that they are unequal (or at least might be unequal) should not be discarded. It's important to the structure.