An Alternate Way
Explore how lazy evaluation helps maintain referential transparency within functional programming in Scala. Understand the benefits of controlling side effects and see how pure code allows easier reasoning. Learn about Scala libraries like Cats, http4s, and Doobie and prepare to contrast pure and impure approaches by implementing services with Akka-HTTP and Slick first.
We'll cover the following...
We'll cover the following...
Maintaining referential transparency
In the previous lesson, we saw how important referential transparency is for functional programming. If we want referential transparency, we must push the side effects to the boundaries of our system (program). This can be done by using lazy evaluation.
Let’s see what lazy evaluation is by repeating the example from the ...