<p>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:</p>

<p>$$
\circ:  (a \rightarrow a) \times (a \rightarrow a) \rightarrow (a \rightarrow a)
$$</p>

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

<pre><code>class Monoid a where
    mempty  :: a
    -- ^ Identity of 'mappend'
    mappend :: a -&gt; a -&gt; a
    -- ^ An associative operation
</code></pre>

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

CC BY-SA 3.0
2015-01-15T14:24:04.803Z
See https://en.wikipedia.org/wiki/Monoid . The categorical interpretation is an afterthought.
Emil Jeřábek
CC BY-SA 3.0
2015-01-15T19:59:35.027Z
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
CC BY-SA 3.0
2015-01-20T17:44:15.360Z
IMO this question is appropriate for http://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
<ct.category-theory>
How to derive a monoid's append from category theory
Vittorio Zaccaria
# How to derive a monoid's append from category theory

(Asked by: username_0 on 2015-01-15)

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.

**Tags:** ct.category-theory
> **Comments:**
> **username_1**: See https://en.wikipedia.org/wiki/Monoid . The categorical interpretation is an afterthought.  
> **username_1**: 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.  
> **username_2**: IMO this question is appropriate for http://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.  

---

## 0 answers

