Cofun with Cofree Comonads
Monads, monad transformers and free monads are commonly used and understood, but the comonadic equivalents have received a lot less attention. The goal of this talk is to discuss comonads, comonad transformers, and cofree comonads.the different perspective they provide, and how they can be used as a better abstraction for some problems.
The first half of the talk will be building up the intuition for what comonads and comonad transformers are for and how you can use them.
This will be done by comparing and contrasting various comonadic entities with their monadic equivalents, poking around with some concrete instances, and demonstrating some examples of comonads and comonad transformers in use.
The second half of the talk will be about cofree comonads, how they relate to free monads, and how we can use them together to do exciting things.
We’ll start with a quick recap of free monads, which we’ll use to develop a little language which will be the basis for our running example.From this we’ll develop a corresponding cofree comonad while explaining the intuition behind them, after which we’ll show how they can be made to work together.
We’ll end with a demonstration of how this is useful, and a whirlwind tour of some of the opportunities this opens up.