Now that you’ve mastered the difference between eager and lazy evaluation, you are going to learn about cats.effect.IO
. Impure functions produce side effects. The type IO
, which is part of the cats-effect library, allows you to represent synchronous and asynchronous side effects lazily. You’ll be able to separate the definition of what to execute from its actual execution, making it easier to maintain and test. You can consider the type IO
as the lazy alternative to the eagerly evaluated Future
. After discussing why lazily evaluating side effects can be advantageous, you’ll see how to represent and execute side effects that are either synchronous or asynchronous. In the capstone, you’ll use the type IO
to define side effects in your quiz application.