In the previous lesson, you learned the basics of the type IO
. You’ll now see how to compose smaller side effects to create programs you can lazily describe and run. You’ll master how to use the map
and flatMap
operations to manipulate values that impure functions produce. You’ll discover how to combine them in sequence using for-comprehension
. Also, you’ll see how to run them in parallel using the parSequence
method. In the capstone, you’ll combine multiple IO
instances to define the operations of your quiz application.
The IO
type offers implementations for the map
and flatMap
methods. They are consistent with those for Future
and the other types you have encountered thus far. Let’s recap their usage in the following sections. You are going to code using the IO
type. Do not forget to add cats-effect as an external dependency for your sbt project by adding the following instruction to your build.sbt file: