• demesisx@infosec.pub
    link
    fedilink
    English
    arrow-up
    12
    ·
    9 months ago

    On the latest Haskell interlude podcast, the guest was talking about how using the ReaderT monad specifically introduces safety issues. My ears perked up because I’m right in the middle of leaning on it heavily in one of my Haskell projects.

  • Corbin@programming.dev
    link
    fedilink
    English
    arrow-up
    1
    ·
    9 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.)