Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Don't understand notation of morphisms in Monoid definition

I'm trying to understand what Monoid is from a category theory perspective, but I'm a bit confused with the notation used to describe it. Here is Wikipedia:

In category theory, a monoid (or monoid object) (M, μ, η) in a monoidal category (C, ⊗, I) is an object M together with two morphisms

μ: M ⊗ M → M called multiplication,

η: I → M called unit

My confusion is about the morphism notation. Why is the binary operation a part of the morphism notation? My understanding of a morphism is that it's a kind of function that can map from one type to another (domain to codomain), like M → M. Why is the operation a part of the domain in the definition? The second confusion is about I. Why is I a domain? There is no I object in a Monoid at all. It's just a neutral element of the object M.

I understand that Monoid is a category with one object, an identity morphism, and a binary operation defined on this object, but the notation makes me think that I don't understand something.

Is M ⊗ M somehow related to the cartesian product, so that the domain of the morphism is defined as M x M?

Edit: I got a really helpful answer for my question on the Mathematics Stack Exchange.

like image 545
Bogdan Vakulenko Avatar asked May 18 '19 15:05

Bogdan Vakulenko


1 Answers

Is M ⊗ M some how related to cartesian product, so domain of the morphism is defined as M x M ?

Exactly. More specifically, we get those monoids that are expressed by the Monoid class from base by picking Hask (the category with all Haskell types as objects and all Haskell functions as morphisms) as C, (,) (the pair type constructor) as , and () (the unit type) as I. The signatures of μ and η, translated to Haskell, then become:

μ :: (M, M) -> M
η :: () -> M

By currying μ, and making use of how () -> M functions are in one-to-one correspondence to M values (all of them look like \() -> m for some m), we get the familiar Monoid methods:

mappend :: M -> M -> M
mempty :: M

Note that the categorical definition is far more general than just Monoid. For instance, we might keep working in Hask while replacing (,) and () with their duals, Either and Void, thus getting:

μ :: Either A A -> A
η :: Void -> A

Every Haskell type is a monoid in this particular manner (μ is either id id, and η is absurd).


Another example is taking C to be the category of Haskell Functors (with natural transformations between them -- which I will write as type f ~> g = forall a. f a -> g a -- as morphisms), Compose as , and Identity as I:

-- Note the arrows here are ~>, and not ->
μ :: Compose M M ~> M
η :: Identity ~> M

These two are commonly written as:

-- "Inlining" the definitions of Compose, Identity, and ~>
join :: M (M a) -> M a
return :: a -> M a

In other words, a Monad is a monoid in the category of Functors (which is the Hask-specific version of "a monad is a monoid in the category of endofucntors"). It is worth mentioning that, as in the other example, this is not the only way to get monoids out of that category (see the final paragraph of this answer for pointers -- the rest of it, in fact, might be relevant reading, as it discusses the notion of monoidal category).

like image 51
duplode Avatar answered Oct 31 '22 13:10

duplode