|
|
|
|
|
by cousin_it
3361 days ago
|
|
Functions of type A -> A for some A form a monoid under composition, but functions of arbitrary type don't. The nifty phrase "a monad is just a monoid in the category of endofunctors" doesn't refer to the function composition monoid, but something much stranger, where the "composition" operation has type m (m a) -> m a, and the "identity" operation has type a -> m a. To understand how that can be seen as a monoid, note that the composition operation composes two effects on the same computation, and the identity operation adds an empty effect. |
|
Thanks - While I did have this vague idea, and it says it from the types, seeing it written out in this way was clarifying.