Maybe you were mainly just thinking of monad transformers or combining discrete monads?
Maybe you were mainly just thinking of monad transformers or combining discrete monads?
Algebraic effects are a restriction on monads, but a restriction that still allows for the vast majority of use cases. In return, you get composability and a clear separation of effectful operations and effect handling.
The default of using monads for everything produces too much cognitive complexity for little benefit.
I'm also not sure what you mean by "using monads for everything." Monads are basically just flatten and map. It sounds kind of like "you're using map for everything" to which the answer seems something along the lines of, well in a lot of places where you use map, if you didn't use map, you'd probably just reinvent it.
Yep, it is a restriction as I said. Algebraic effects basically live inside the free monad, so that's what I meant by that.
This restriction, versus using separate Writer, IO, etc, monads, is far more easy to reason about. Types in Haskell become insane with monad transformers. It produces code that is difficult to understand and reuse.
edit: Algebraic effects can also be derived from delimited continuations.
Totally agree about the brittle and type-soup nature of transformer-heavy code.
However, it is also true that you cannot encode, e.g., the continuation monad using (typed) algebraic effects. The precise relationship isn't that simple, but this paper:
https://arxiv.org/abs/1610.09161
analyzes a particular setting in detail.Jake Keuhlen spoke about it at LambdaConf this year [0] [1], and John De Goes spoke a bit on the notion of Arrow-ized IO in the `zio` library for Scala that offers an alternative interface for `IO` effects [2].
Will Fancher has also written a bit on the concept of "Free Arrows", but it's a much deeper dive (IMO) than the previous resources [3].
[0] Keuhlen's Repo: https://github.com/jkeuhlen/talks/tree/master/extensibly-fre...
[1] Keulen's Slides: https://github.com/jkeuhlen/talks/blob/master/Extensibly%20F...
[2] https://github.com/scalaz/scalaz-zio/blob/master/core/shared...
[3] https://elvishjerricco.github.io/2017/03/10/profunctors-arro...