Book Image

Learn Scala Programming

By : Slava Schmidt
Book Image

Learn Scala Programming

By: Slava Schmidt

Overview of this book

The second version of Scala has undergone multiple changes to support features and library implementations. Scala 2.13, with its main focus on modularizing the standard library and simplifying collections, brings with it a host of updates. Learn Scala Programming addresses both technical and architectural changes to the redesigned standard library and collections, along with covering in-depth type systems and first-level support for functions. You will discover how to leverage implicits as a primary mechanism for building type classes and look at different ways to test Scala code. You will also learn about abstract building blocks used in functional programming, giving you sufficient understanding to pick and use any existing functional programming library out there. In the concluding chapters, you will explore reactive programming by covering the Akka framework and reactive streams. By the end of this book, you will have built microservices and learned to implement them with the Scala and Lagom framework.
Table of Contents (19 chapters)

A Look at Monad Transformers and Free Monad

In Chapter 6, Exploring Built-In Effects, we looked at standard effects and promised to reveal the truth about the concepts underlying them; we also discussed the topic of combining them. Since then, we have discussed algebraic structures, such as monoids and groups, functors, applicatives, and monads, delivering on our first promise. But the composition topic has remained uncovered all this time.

In Chapter 8, Dealing with Effects, we implemented a general way to compose applicatives—which is very useful on its own, but can't help us with combining the standard effects of a monadic nature.

In this chapter, we will finally take on and keep our second promise by discussing some ways to bring different monadic effects together. We will look at the complications related to that and some of the solutions used in the Scala community...