|
|
|
|
|
by BoiledCabbage
3358 days ago
|
|
Not to be pedantic, but if someone understands monoids well from abstract algebra and someone else says: "By the way, in addition to all the existing monoids you know (Ints under '+', strings, lists...), functions under function composition also form a monoid. Here's an example." Isn't that pretty much getting them to the same place? Do they really need a study of category theory? |
|
Not quite function composition, but given a type a, (a ->) is a monad (the so called "reader monad"). We have
(Incidentally, these are two of the Łukasiewicz axioms for propositional calculus.)It is a functor with
In the case x=y, then fmap takes the monoid of functions on x to the monoid of functions on (a -> x).Venturing into more abstract territory, "a monad is a monoid in the category of endofunctors of a category C." (This has never helped me with understanding how to use monads in Haskell.) Basically, the choice of endofunctor is the type constructor for the monad, the unit map is `return` and the composition map is `join`.