Apr 27, The definitions of monads and monoids on the one hand, a binary relation between X and Y. Thus, the Kleisli category SetP is isomorphic to. Sep 6, The notion of a category itself arises at all levels of abstraction, and so does the concept of a monoid and a monad. Which one is the most basic. Sep 20, Monads are known to be monoids in a monoidal category of explicit the relation between applicative functors and monoids with respect Functional Programming Languages and Computer Architecture, pages –
A simple way to combine function is composition: Let's take our examples above, and compose each function with itself: Without getting too much into type theory, the point is that you can combine two integers to get an integer, but you can't always compose two functions and get a function of the same type. So, let's define a different way of combining functions. When we combine two of these functions, we don't want to "double-wrap" the results.
Here is what we do. When we want to combine two functions F and G, we follow this process called binding: Compute the "results" from F but don't combine them. Compute the results from applying G to each of F's results separately, yielding a collection of collection of results. Flatten the 2-level collection and combine all the results. Back to our examples, let's combine bind a function with itself using this new way of "binding" functions: This more sophisticated way of combining functions is associative following from how function composition is associative when you aren't doing the fancy wrapping stuff.
Tying it all together, a monad is a structure that defines a way to combine the results of functions, analogously to how a monoid is a structure that defines a way to combine objects, where the method of combination is associative, and where there is a special 'No-op' that can be combined with any something to result in something unchanged. But these were just sanity checks. A functor is defined as a mapping of categories. A functor turned out to be a morphism in the category of categories small categories, if we want to avoid questions about size.
By treating a functor as an arrow, we forfeit the information about its action on the internals of a category its objects and morphismsjust like we forfeit the information about the action of a function on elements of a set when we treat it as an arrow in Set.Category Theory 10.2: Monoid in the category of endofunctors
But functors between any two categories also form a category. This time you are asked to consider something that was an arrow in one category to be an object in another. In a functor category functors are objects and natural transformations are morphisms. We have discovered that the same thing can be an arrow in one category and an object in another.
There was a problem providing the content you requested
Instead of switching between two views, we can try to merge them into one. This is how we get the concept of a 2-category, in which objects are called 0-cells, morphisms are 1-cells, and morphisms between morphisms are 2-cells. The category of categories Cat is an immediate example. We have categories as 0-cells, functors as 1-cells, and natural transformations as 2-cells.
The laws of a 2-category tell us that 1-cells between any two 0-cells form a category in other words, C a, b is a hom-category rather than a hom-set. This fits nicely with our earlier assertion that functors between any two categories form a functor category.
In particular, 1-cells from any 0-cell back to itself also form a category, the hom-category C a, a ; but that category has even more structure. Members of C a, a can be viewed as arrows in C or as objects in C a, a. As arrows, they can be composed with each other. But when we look at them as objects, the composition becomes a mapping from a pair of objects to an object.
In fact it looks very much like a product — a tensor product to be precise. This tensor product has a unit: It turns out that, in any 2-category, a hom-category C a, a is automatically a monoidal category with the tensor product defined as composition of 1-cells.
Associativity and unit laws simply fall out from the corresponding category laws.
Monads, Monoids, and Categories | Bartosz Milewski's Programming Cafe
The hom-category Cat a, a is the category of endofunctors on a. Endofunctor composition plays the role of a tensor product in it. The identity functor is the unit with respect to this product. You might recall that, in a general monoidal category, we did not insist on the monoid laws being satisfied on the nose.
It was often enough for the unit laws and the associativity laws to be satisfied up to isomorphism. In a 2-category, monoidal laws in C a, a follow from composition laws for 1-cells.
These laws are strict, so we will always get a strict monoidal category. It is, however, possible to relax these laws as well. We can say, for instance, that a composition of the identity 1-cell ida with another 1-cell, f:: Isomorphism of 1-cells is defined using 2-cells. In other words, there is a 2-cell: We can do the same for the left identity and associativity laws.
This kind of relaxed 2-category is called a bicategory there are some additional coherency laws, which I will omit here. As expected, endocells in a bicategory form a general monoidal category with non-strict laws. An interesting example of a bicategory is the category of spans. A span between two objects a and b is an object x and a pair of morphisms: Here, we want to look at spans as 1-cells in a bicategory. The first step is to define a composition of spans. Suppose that we have an adjoining span: The most natural choice for it is the pullback of g along f'.
Remember that a pullback is the object z together with two morphisms: