Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What are Haskell's monad transformers in categorical terms?

As a math student, the first thing I did when I learned about monads in Haskell was check that they really were monads in the sense I knew about. But then I learned about monad transformers and those don't quite seem to be something studied in category theory.

In particular I would expect them to be related to distributive laws but they seem to be genuinely different: a monad transformer is expected to apply to an arbitrary monad while a distributive law is an affair between a monad and a specific other monad.

Also, looking at the usual examples of monad transformers, while MaybeT m composes m with Maybe, StateT m is not a composition of m with State in either order.

So my question is what are monad transformer in categorical language?

like image 595
Omar Antolín-Camarena Avatar asked Jul 28 '11 05:07

Omar Antolín-Camarena


2 Answers

Monad transformers aren't exceedingly mathematically pleasant. However, we can get nice (co)products from free monads, and, more generally, ideal monads: See Ghani and Uustalu's "Coproducts of Ideal Monads": http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.4.2698

like image 156
sclv Avatar answered Oct 08 '22 02:10

sclv


Calculating monad transformers with category theory by Oleksandr Manzyuk is another article on the Monad transformers, and relates the concept to the important concept of adjunction in the category theory.
Also it uses the most pleasant feature of the category theory, in my opinion, i.e. diagram-chasing, which naturalises the concept a lot.
Hope this helps.

like image 27
awllower Avatar answered Oct 08 '22 02:10

awllower