In this chapter and the previous chapters, we represented sequenced computations with monads. The flatMap method of the monad describes how the computation steps should be joined and the function given to it as an argument—the computation step itself. The free monad elevates the concept of sequenced computations to the next level.
First, we start to represent the computation steps as instances of some ADT (algebraic data type) of our choice. Second, we represent the monadic concept with instances of another ADT.
To substantiate this approach, we can turn to the fishing example once again. Earlier, we had three actions we encoded as functions. These actions will be represented as value classes now. We also need to give specific meaning to the type aliases we've used before to be able to run examples later.
Here is the definition of the fishing model and...