A Writer monad works with an assumption that the write state is an instance of a monoid. As a monoid, you will get two properties:
- mempty: This is a scratch value
- mappend: This is a way to combine two values
A Writer monad hence starts with an empty (or scratch) value. As we use the function tell in the context of Writer monad, the Writer monad keeps combining the existing value with a new value and updates the writer state.
In our recipe, we used Transaction and its monoid instance to keep our balance sheet automatically updated.