Combine Free Monad Algebra with Scalaz.

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!

A software engineer and a functional programming enthusiast at Simple-machines, Sydney, and a hardcore hiking fan.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store