Regarding (3): you’re right, with your notion of handler the handlers would have to be generic in the return values. Man handlers are like that (sate, I/O), but some important ones are not, for instance, a handler which handles non-deterministic choice and computes the maximum possible return value relies on the fact that return values can be compared. I think handlers arise as a combination of two requirements: we want to use free algebras to model computations, and we want handlers to be algebra homomorphisms. Assuming these requirements, we have several options. Of these, the one presented is the one that programmers seem to be most happy with. This is an empirical observation. (In fact, some programers want “shallow” handlers which correspond to maps between carriers, ignoring algebra structures). I know this is not much of a mathematical explanation, but you are threading into computer science territory :)

]]>Regarding (2), in Haskell one often has the problem of “combining” monads, which has no general solution; algebraic effects seem to solve this. Is the algebraic “monad coproduct” approach at all related to Haskell’s “monad transformers” that allow certain monads to be combined with any other monad?

Regarding (3), I am a little puzzled by the notion of handler from a mathematical perspective. It seems to me that the mathematically natural way to talk about a homomorphism from F_T(X) to F_{T’}(X’) would be to ask for a monad morphism from T to T’, thereby making *every* T’-model into a T-model functorially, and then a T-homomorphism from F_T(X) to F_{T’}(X’) (hence a set-map from X to F_{T’}(X’)). Syntactically, I think this means that the operation handlers would not be allowed to know or use the “return type” of the with-handle expression, instead being forced to return a value constructed in a generic way from the supplied continuation. Of course this would rule out basic things like exception handlers (Example 3.1), so it’s not as useful. But can you give any more mathematical intuition for the notion of handler?