The Scalaz library
Scala is a functional programming language and as such it supports design patterns based on concepts such as monoids, monads, and others. We already saw these in Chapter 10, Functional Design Patterns – The Deep Theory, and we know the rules they follow and the structure they have. We wrote everything ourselves, but a library already exists that does this for us—Scalaz (https://github.com/scalaz/scalaz). This library is used when we need purely functional data structures.
We have already encountered Scalaz in the previous chapter when we talked about lenses. In the following subsections, we will look at the library from the point of view of monoids, functors, and monads.
Monoids in Scalaz
One of the concepts we looked at in Chapter 10, Functional Design Patterns – The Deep Theory was monoids. We defined a trait and some rules for them and then showed examples of how to use them and what they are good for. In these examples, we defined monoids for integer...