The definition of "Monads is just monoids in the category of endofuntors", which, although true, is a bad place to start. This is from a message that was mainly intended as a joke. But if you are interested in correspondence, this can be demonstrated in Haskell:
Description of non-professionals categories is an abstract collection of objects and morphisms between objects. Comparisons between categories are called functors and map objects for objects and morphisms for morphisms associatively and identities are preserved. Entofuctor is a functor from the category into itself.
{-# LANGUAGE MultiParamTypeClasses, ConstraintKinds, FlexibleInstances, FlexibleContexts #-} class Category c where id :: cxx (.) :: cyz -> cxy -> cxz class (Category c, Category d) => Functor cdt where fmap :: cab -> d (ta) (tb) type Endofunctor cf = Functor ccf
Mappings between functors that satisfy the conditions of the identifier of the triangle and the identifier of associativity and are defined as:
In Haskell, μ is join and η is return
return :: Monad m => a -> majoin :: Monad m => m (ma) -> ma
A categorical definition of Monad in Haskell can be written:
class (Endofunctor ct) => Monad ct where eta :: ca (ta) mu :: c (t (ta)) (ta)
The binding operator can be obtained from them.
(>>=) :: (Monad ct) => ca (tb) -> c (ta) (tb) (>>=) f = mu . fmap f
This is a complete definition, but, equivalently, you can also show that Monad laws can be expressed as monoid laws with a functor category. We can construct this category of functors, which is a category with objects as functors (i.e., Mappings between categories) and natural transformations (i.e., Mappings between functors) as morphisms. In the category of endofunctors, all functors are functors between the same category.
newtype CatFunctor ctab = CatFunctor (c (ta) (tb))
We can show that this leads to a category with functor composition as a composition of morphism:
-- Note needs UndecidableInstances to typecheck instance (Endofunctor ct) => Category (CatFunctor ct) where id = CatFunctor id (CatFunctor g) . (CatFunctor f) = CatFunctor (g . f)
A monoid has the usual definition:
class Monoid m where unit :: m mult :: m -> m -> m
The monoid over the category of functors has natural transformations as the identity a and the multiplication operation, which combines the natural transformations. The composition of Claysley can be determined to satisfy the law of multiplication.
(<=<) :: (Monad ct) => cy (tz) -> cx (ty) -> cx (tz) f <=< g = mu . fmap f . g
And so you have it: "Monads are simply monoids in the category of endofentors", which is simply a "meaningless" version of the normal definition of monads from endofuntors and (mu, eta).
instance (Monad ct) => Monoid (ca (ta)) where unit = eta mult = (<=<)
With some substitution, it can be shown that monoidal properties (<=<) are equivalent statements of triangle diagrams and associativity for natural monad transformations.
f <=< unit == f unit <=< f == f f <=< (g <=< h) == (f <=< g) <=< h
If you are interested in diagrammatic representations, I wrote a little about representing them with string diagrams.