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)

Summary

Monads are arguably the most ubiquitous abstraction in functional programming. Unfortunately they cannot be composed in general—in contrast to functions and applicatives.

Monad transformers provide a way to work around this limitation by specifying a set of overarching structures to represent combinations of monads, each combination being specific to a single internal effect type. Monad transformers compose monads in a way that it is possible to cross both effects with a single call of the flatMap or map.

Monad transformer stacks lift the concept of monad transformers one level higher, utilizing the fact that each monad transformer is also a monad. By stacking monad transformers, it is possible to work with virtually any number of effects combined together in a single pile the same way we would do with a single monad.

Monad transformers are not without disadvantages...