Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

The paragraph starting "As each object in this category..." made no sense to me. I can explain the what a monoid in the category of endofunctors is, how it relates to a Haskell monad and maybe you can explain what you meant.

OK, a monoid in the category of endofunctors is an endofunctor F together with a natural transformation (the multiplication of the monoid) from F composed with F to F, and another natural transformation from id to F (called the unit). In Haskell F is the type constructor of the monad, the unit is called return and the multiplication is usually called join (and in the case of the list monad is also known as concat).

(Note that the definition of monoid needed here is not that of a set with associative binary operation, but the more general "monoid object in a monoidal category". Instead of a set S and a multiplication S x S->S, where x denotes cartesian product, we want a functor F and a multiplication F o F->F where o denotes composition. This is an instance of the general sort of monoid since the category of endofunctors is monoidal with respect to composition.)



I didn't want to give the full categorical definition in terms of what a monoidal category allows, because I don't think that adds much, but I suppose I flubbed making it simpler. I just wanted to make the point that the monoidal portion determines how the composition occurs -- a given type constructor can be a monad multiple ways.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: