August 2018
Intermediate to advanced
380 pages
10h 2m
English
Let us have a look at how you can use type classes from the Cats library on an example of Monad, the type class we are already familiar with.
In the previous sections, in order to use a Monad type class, we defined it as ad hoc. However, the Cats library provides all of the abstractions we need so that we don't need to define this type class and its syntax ourselves.
So, how do you use the Monad type class in the context of the logging example from Chapter 7, The Idea of the Type Classes? As you may recall, in that chapter, we took a look at an example of logging capabilities and discussed that it is a good example of the sequential composition that can be handled by Monad. So, let's take a look at how this can be done with cats: