For over two decades, monad transformers have been the main modular approach for expressing purely functional side-effects in Haskell. Yet, in recent years algebraic effects have emerged as an alternative whose popularity is growing. While the two approaches have been well-studied, there is still confusion about their relative merits and expressiveness, especially when it comes to their comparative modularity. This paper clarifies the connection between the two approaches---some of which is folklore---and spells out consequences that we believe should be better known. We characterise a class of algebraic effects that is modular, and show how these correspond to a specific class of monad transformers. In particular, we show that our modular algebraic effects gives rise to monad transformers. Moreover, every monad transformer for algebraic operations gives rise to a modular effect handler.
@article{haskell2019a,
author = {Tom Schrijvers and Maciej Pirog and Nicolas Wu and Mauro Jaskelioff},
title = {Monad Transformers and Modular Algebraic Effects: What Binds Them Together},
journal = {ACM SIGPLAN Notices},
year = {2019},
url = {/Research/papers/haskell2019a.pdf},
talk = {/Research/talks/haskell2019a.pdf},
abstract = {For over two decades, monad transformers have been the main modular
approach for expressing purely functional side-effects in Haskell. Yet, in
recent years algebraic effects have emerged as an alternative whose popularity is growing.
While the two approaches have been well-studied, there is still confusion
about their relative merits and expressiveness, especially when it comes to their comparative modularity. This paper clarifies the connection between the two approaches---some of which is folklore---and spells out consequences that we believe should be better known.
We characterise a class of algebraic effects that is modular, and show how these correspond to a specific class of monad transformers. In particular, we show that our modular algebraic effects gives rise to monad transformers. Moreover, every monad transformer for algebraic operations gives rise to a modular effect handler.
},
}