Free monad or tagless final? How not to commit to a monad too early.
Functional programming is on the rise; monads are everywhere. But how to choose the right wrapper for the values which we manipulate (i.e. monad)? Quite often, the answer is far from obvious, and it’s useful to delay the decision as much as possible. Furthermore, picking a particular monad too early might only obscure important business logic details.
There are (at least) two ways to solve the problem, which are quite popular: free monads and the tagless final encoding. Both are equivalent in expressive power, but are radically different when it comes to code.
In this live-coding talk we’ll see how to transform a simple application which relies on `Future`s into more generic forms, using either the free monad or tagless final. We’ll see how these two representations compare in terms of boilerplate, readability, composability and stack-safety. We’ll also discuss which approach might be a better fit for selected use-cases.
I am one of the co-founders of SoftwareMill, where I code mainly using Scala and other interesting technologies. I am involved in open-source projects, such as sttp, MacWire, Quicklens, ElasticMQ and others. I have been a speaker at major conferences, such as JavaOne, LambdaConf, Devoxx and ScalaDays.
Apart from writing closed- and open-source software, in my free time I try to read the Internet on various (functional) programming-related subjects. Any ideas or insights usually end up with a blog (https://softwaremill.com/blog)
Pizza will be provided, sponsored by Nexstar Digital.
Nexstar Digital is on the 8th floor of the Omni Hotel office building downtown (same building as Capital Factory, different floor). Elevators are security controlled, so text[masked] or[masked] for assistance.
We can meet each other and network around 6:30PM. We'll kick off the discussion at 7:00PM.