this post was submitted on 27 Mar 2024
41 points (87.3% liked)

Functional Programming

1393 readers
1 users here now

founded 1 year ago
MODERATORS
you are viewing a single comment's thread
view the rest of the comments
[–] Corbin 1 points 7 months ago

I've recently come to appreciate monads as 2-arrows from the terminal object in a 2-category; quoting nLab:

… a monad in [a category] K is a lax 2-functor from the terminal bicategory 1 to K: the unique object * of 1 is sent to the object a, the morphism 1 becomes [the endomorphism] t, and [the unit] η and [the join] μ arise from the coherent 2-cells expressing lax functoriality.

This is a nifty demystification of the data of a monad. Why do endofunctors tend to carry monads? Because endofunctors on categories C tend to be expressible as endomorphisms in 2-categories where C is an object! Since this latter condition is typically trivial, it follows that endofunctors on C typically carry monads (and that any counterexamples depend on the structure of C and choice of 2-category.)