Essentials: First Steps With ZIO
ZIO will help you build modern applications that are concurrent, resilient, efficient, and easy to understand and test. But learning ZIO requires thinking about software in a whole new way—a way that comes from functional programming.
This chapter will teach you the critical theory you need to understand and build ZIO applications.
We will start by introducing the core data type in ZIO, which is called a functional effect type, and define functional effects as blueprints for concurrent workflows. We will learn how to combine effects sequentially and see how this allows us to refactor legacy code to ZIO.
We will discuss the meaning of each of the type parameters in ZIO’s core data type, particularly the error type and the environment type, which are features unique to ZIO. We will compare ZIO to the Future data type in the Scala standard library to clarify the concepts we introduce.
We will see how we can leverage the default services built into ZIO for interacting with time, the console, and system information (among others). Finally, we’ll see how recursive ZIO effects allow us to loop and perform other control flow operations.
By the end of this chapter, you will be able to write basic programs using ZIO, including those that leverage environmental effects and custom control flow operators, and you will be able to refactor legacy code to ZIO by following some simple guidelines.
