Composability
We can achieve monadic function composition
with Kleisli Arrows
A
M[B]
In other words a function that
for a given input it returns a type constructor…
List[B], Option[B], Either[B], Task[B],
Future[B]…

Interpretation : Free Monads
At this point a program like this is nothing but
Data
describing the sequence of execution but FREE
of it's runtime interpretation.
val program = for {
a <- ask(1)
b <- async(2)
_ <- tell(println("log something"))
} yield a + b

Solving the Puzzle
How do we assemble a type that is:
Kleisli + Custom ADT + Result
for {
a <- Kleisli((x : String)
b <- Kleisli((x : String)
ask(Result.catching[NumberFormatException](x.toInt)))
ask(Result.catching[IllegalArgumentException](x.toInt)))
} yield a + b
We want a and b to be seen as Int but this won't
compile
because there are 3 nested monads