categories and monoids (was: Re: [Haskell-cafe] Design Patterns by Gamma or equivalent)

Jonathan Cast jonathanccast at fastmail.fm
Tue Mar 17 11:32:36 EDT 2009

```On Tue, 2009-03-17 at 13:06 +0100, Wolfgang Jeltsch wrote:
> Am Dienstag, 17. März 2009 10:54 schrieben Sie:
> > Wolfgang Jeltsch <g9ks157k at acme.softbase.org> writes:
> > > By the way, the documentation of Control.Category says that a category is
> > > a monoid (as far as I remember). This is wrong. Category laws correspond
> > > to monoid laws but monoid composition is total while category composition
> > > has the restriction that the domain of the first argument must match the
> > > codomain of the second.
> >
> > I'm reading the Barr/Wells slides at the moment, and they say the
> > following:
> >
> > "Thus a category can be regarded as a generalized monoid,
>
> What is a “generalized monoid”? According to the grammatical construction
> (adjective plus noun), it should be a special kind of monoid, like a
> commutative monoid is a special kind of monoid. But then, monoids would be
> the more general concept and categories the special case, quite the opposite
> of how it really is.
>
> A category is not a “generalized monoid” but categories (as a concept) are a
> generalization of monoids. Each category is a monoid, but not the other way
> round.

You mean ``each monoid is a category, but not the other way round''.

> A monoid is clearly defined as a pair of a set M and a (total) binary
> operation over M that is associative and has a neutral element. So, for
> example, the category of sets and functions is not a monoid. First, function
> composition is not total if you allow arbitrary functions as its arguments.
> Second, the collection of all sets is not itself a set (but a true class)
> which conflicts with the above definition which says that M has to be a set.
>
> > or a 'monoid with many objects'"
>
> What is a monoid with many objects?

A categorical definition of a monoid (that is, a plain old boring monoid
in Set) is that it is a category with a single object.  A category is
thus a monoid with the restriction to a single object lifted :)

jcc

```