5 thoughts on “Stackless Scala with Free Monads

  1. Hi Rúnar, very much enjoyed reading this paper. Couple of questions:

    1. Would it be possible, using a State monad, to implement a Cucumber-like BDD framework, such that each GIVEN/WHEN/THEN step returns a State, which in turn is passed as an input to each subsequent step, thereby eliminating the mutation of common state in test steps?

    2. Would this be desirable, for example in the Play 2.0 / TypeSafe stack?

    3. Has anyone done this yet in scala?

    Thanks,
    -Marc

    • Yeah, that would be totally doable. In fact, you can generalize that solution to an IO monad which is just Free[({type f[x] = Either[I => x, (O, x)})] where I is the type of input signals and O is the type of output signals. What you describe is just a generalization of that monad.

      I don’t think anyone has done exactly what you describe, but I’ve sketched out e.g. client/server program (a REPL for a simple language) where O is executable javascript and I is AJAX requests. The client (running in a browser) can then be seen as a machine that turns Os into Is.

      Runar

Leave a comment