As mentioned in the ZIO documentation page: “A module is a group of functions that deals with only one concern. Keeping the scope of a module limited, improves our ability to understand code, in that we need to focus on only one topic at a time without juggling too many concepts at the same time in our head”.
The idea is that ZIO allows us to define modules and use them to create different application layers relying on each other. This means each layer depends on the layers immediately below it, although it doesn’t know anything about their implementation details. This is a really powerful concept, because it improves composability and testability (because you can easily change each module’s implementation without affecting other layers).
Now, if you are thinking about how to define these modules, ZIO provides us with a nice recipe to follow when defining a new module:
Don’t worry if this all seems too abstract at the moment, because we are going to be applying this recipe for reimplementing the Tic-Tac-Toe application later. The important thing for now is to realise that two important data types are mentioned in this recipe: ZLayer and Has. So let’s discuss those now.