concept purity in category scala

This is an excerpt from Manning's book Get Programming with Scala.
In this lesson, you’ll learn about purity, a fundamental principle of functional programming. In particular, you are going to see that a pure function is total and it has no side effects: do not worry if you do not know what these terms mean, as I’ll explain them in detail later in this lesson. When coding, being able to distinguish between pure and impure functions can help you identifying and prevent bugs in your code. For example, consider the following scenario:

This is an excerpt from Manning's book Functional Programming in Scala.
Formalizing the notion of purity this way gives insight into why functional programs are often more modular. Modular programs consist of components that can be understood and reused independently of the whole, such that the meaning of the whole depends only on the meaning of the components and the rules governing their composition; that is, they are composable. A pure function is modular and composable because it separates the logic of the computation itself from “what to do with the result” and “how to obtain the input”; it’s a black box. Input is obtained in exactly one way: via the argument(s) to the function. And the output is simply computed and returned. By keeping each of these concerns separate, the logic of the computation is more reusable; we may reuse the logic wherever we want without worrying about whether the side effect being done with the result or the side effect requesting the input are appropriate in all contexts. We saw this in the buyCoffee example—by eliminating the side effect of payment processing being done with the output, we were more easily able to reuse the logic of the function, both for purposes of testing and for purposes of further composition (like when we wrote buyCoffees and coalesce).
Up until this point, you may have had the impression that in purely functional programming, you’re not allowed to use mutable state. But if we look carefully, there’s nothing about the definitions of referential transparency and purity that disallows mutation of local state. Let’s refer to our definitions from chapter 1:
Definition of referential transparency and purity