Connecting...

W1siziisimnvbxbpbgvkx3rozw1lx2fzc2v0cy9zawduawz5lxrly2hub2xvz3kvanbnl2jhbm5lci1kzwzhdwx0lmpwzyjdxq

Free monad or tagless final? How not to commit to a monad too early by Adam Warski

W1siziisijiwmtkvmdgvmdivmtavntkvntivndmzl3blegvscy1wag90by0zntywnzkuanblzyjdlfsiccisinrodw1iiiwiotawedkwmfx1mdazzsjdxq

Monads are everywhere!

However, choosing a particular monad may obscure business logic but there is a way to solve this and Adam Warski showed us how at ScalaIO.

 

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 Futures 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.
 
 
 
This talk was given by Adam Warski at ScalaIO