Calculating monad transformers with category theory
Oleksandr Manzyuk
TL;DR
This work shows that state, writer, reader, and error monad transformers can be uniformly obtained by translating a monad along an adjunction, encapsulated by the construction P = UTF. By instantiating the general translation to specific adjunctions (e.g., F = -×S, U = (-)^S for state; F = X×M, U forgetful for writer; environment-based reader; and E/Set for error), it derives concrete transformer monads and their unit and multiplication from the adjunction and the base monad. The approach unifies several transformers under a single categorical mechanism and connects to strength and distributive-law ideas, while noting that continuation monad transformers fall outside this framework. The results provide both a principled theoretical lens and practical translation rules that illuminate how these transformers arise from adjunctions and lifted monads.
Abstract
We show that state, reader, writer, and error monad transformers are instances of one general categorical construction: translation of a monad along an adjunction.
