Interpret your monads! - Concrete Monads vs Monad classes by Auke Booij #FnConf 2022
Channel: ConfEngine
Date: 30/03/2022

Concrete monads or monad classes? I'll tell you why it often makes sense to jump around between these options, and where this comes from.
Monads are the central notion to encode a program with effects in Haskell. Nowadays, we often combine several monad transformers to create the desired effect stack, relying on mmorph to juggle effects as required. But in fact, monad transformers and monad morphisms are just as old as monads in functional programming, an idea first published in 1989.

We can still benefit from that old work. The core of this talk is to discuss monads which are initial objects in the sense of category theory. Practically, this means that such monads can be interpreted in a class of other monads. Perhaps the most well-known example of such initial monads is Either e, which can be interpreted in any monad that instantiates MonadError e, through the use of liftEither.

This general principle of monad interpretation is exactly what allows us to jump around between concrete monads and monad classes. Monad interpretation can sometimes give a free performance boost, and can be used to easily write Haskell Arrows code without Arrow syntax.

More details: https://confengine.com/conferences/functional-conf-2022/proposal/16377

Conference Link: https://www.functionalconf.com