Part 2. Functional programs
We now have the foundation to start building real functional programs. In each of the following chapters we will use only immutable values and pure functions, including several higher-order functions.
In chapter 5 we will introduce the most important higher-order function in FP: flatMap
. It helps building sequential values (and programs) in a concise and readable way.
In chapter 6 we will learn how to build sequential programs that may return errors and how to protect ourselves against different corner cases.
We will use chapter 7 to properly introduce you to the world of functional design. We will model data and functions’ parameters in a way that disallows many invalid (from a business perspective) instances and arguments.
Chapter 8 will teach you how to deal with an impure, external, side-effectful world in a safe and functional way. We will do a lot of IO actions (simulating external database or service calls), including many failing ones.
Knowing how to handle errors, model the data and behaviors, and how to use external IO actions will allow us to introduce streams and streaming systems in chapter 9. We will build streams of hundreds of thousands of items using the functional approach.
In chapter 10 we will finally create some functional and safe concurrent programs. We will show how all the techniques from previous chapters are still applicable even in the presence of multiple threads.