2
$\begingroup$

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.

$\endgroup$

closed as off-topic by Emil Jeřábek, Kaveh, R B, cody, Andrej Bauer Jan 17 '15 at 15:42

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "Your question does not appear to be a research-level question in theoretical computer science. For more information about the scope, please see help center. Your question might be suitable for Computer Science which has a broader scope." – Emil Jeřábek, Kaveh, R B, cody, Andrej Bauer
If this question can be reworded to fit the rules in the help center, please edit the question.

  • 5
    $\begingroup$ See en.wikipedia.org/wiki/Monoid . The categorical interpretation is an afterthought. $\endgroup$ – Emil Jeřábek Jan 15 '15 at 14:24
  • 6
    $\begingroup$ 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. $\endgroup$ – Emil Jeřábek Jan 15 '15 at 19:59
  • $\begingroup$ 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. $\endgroup$ – beroal Jan 20 '15 at 17:44