# How to derive a monoid's append from category theory [closed]

As I understand, a monoid $M$ is just a special kind of category; it has only one object and its morphisms can be composed through a composition operation. In principle, if $a$ is the object of the category, the composition operation should have the following signature:

$$\circ: (a \rightarrow a) \times (a \rightarrow a) \rightarrow (a \rightarrow a)$$

However, in functional programming languages, the monoid's append has a different arity; for example in Haskell you have:

class Monoid a where
mempty  :: a
-- ^ Identity of 'mappend'
mappend :: a -> a -> a
-- ^ An associative operation


Ideally, categorical composition and mappend should be related i.e., we should be able to extract one from the other. But I cannot see why.

• See en.wikipedia.org/wiki/Monoid . The categorical interpretation is an afterthought. – Emil Jeřábek Jan 15 '15 at 14:24
• In particular, the monoid $a$ is not an object of your category, it is the category. It has one unnamed object $*$, so effectively $a=({*}\to{*})$, and composition is $({*}\to{*})\to({*}\to{*})\to({*}\to{*})$, that is, $a\to a\to a$. Emphatically, the morphisms ${*}\to{*}$ here are just abstract arrows, not any kind of functions, so it would be unhelpful to represent them as functions in Haskell. – Emil Jeřábek Jan 15 '15 at 19:59
• IMO this question is appropriate for math.stackexchange.com . Actually, this question is useful, because it reveals how superficial knowledge of category theory leads to believing that every morphism is a special case of a function. – beroal Jan 20 '15 at 17:44