In the domain of functional programming, our main goal is referential transparency, which we define in the following way:
An expression e is referentially transparent if we can replace any occurrences of e in any given program with the result of the evaluation of e without changing the behavior of the program.
Building on that, we need pure functions which are:
Only dependent on their input
Have no side effects
This means that our functions will be referentially transparent.
However, the above-mentioned libraries are built upon Future from Scala, which uses eager evaluation and breaks referential transparency.
Let’s look at an example.