Combine Free Monad Algebra with Scalaz.

Afsal Thaj
1 min readMay 1, 2018

Here is my gist that combines the various algebra defined in various parts of the application, using Free Monad with in Scalaz! For those who are impatient, jump straight to line number 58, that handles what Scalaz is missing !

Well, that was useless toy example.

I think , with my experience with Free (learning scalaz, learning the red book, reading Free things, Runar’s paper on Trampoling to Free and in fact implementing free things in production with Scala), I can say operations as data with Free is attractive, but that can bring significant set of boiler plates that is strong enough to damage the entire design of the app if you are doing something non-trivial. So you need to really consider the complexity of your app before you try to make it simple with Free and find ways to hide away boilers from business logic. A blog can’t be your source of truth as most of them including this one talks Free using it’s constructs.

Back to the tangent, what happens if we have three algebras? Well, that was kind of a terrible fight with Scala type system but that’s fine for me personally ! I will also consider the library iotaz to achieve the same with less boiler plates.

Thanks developers ! Have fun developing only robust apps!

--

--

Afsal Thaj

A software engineer, traveller, fitness trainer, hiker, skydiver and I write at times. https://twitter.com/afsalt2