Skip to Content
Mastering Functional Programming
book

Mastering Functional Programming

by Anatolii Kmetiuk
August 2018
Intermediate to advanced
380 pages
10h 2m
English
Packt Publishing
Content preview from Mastering Functional Programming

Monad

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:

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Learning Functional Programming

Learning Functional Programming

Jack Widman

Publisher Resources

ISBN: 9781788620796Supplemental Content