Last Updated: July 14, 2016
·
326
· Brian Zeligson

or for scalaz natural transformation

This is more of a note to self for next opportunity.

Cats did a nice thing by including or on their natural transformation - http://typelevel.org/cats/api/#cats.arrow.NaturalTransformation

BUT

You can get the same thing from scalaz

First make sure your lifting functions support injection to a coproduct, shown here - https://github.com/ethul/typeclass-inject/blob/3ad6070259ffcc9108a490a12281ce3a976d11c6/README.md

The inject typeclass is now part of scalaz core - https://github.com/scalaz/scalaz/pull/502

Then add some syntax to ~> like so - https://gist.github.com/justjoheinz/bcbaa4a4e69e61a1aa96

UPDATE - example is in.

With a little help from this example - https://github.com/stew/reasonably-priced/blob/master/src/main/scala/reasonable/App.scala

Here's the result - https://github.com/beezee/composed-free-scalaz/blob/master/src/main/scala/FreeComposed.scala

This is a completely viable and practical approach to combining free algebras.