Functional design patterns
In the preceding sections of this chapter, we have compared functional and object-oriented design patterns (strategy, decorator, and Dependency Injection/IoC). If we look at the main differences between the functional and object-oriented patterns, it becomes clear that our patterns are achieved through different combinations of functions. We are either using functions as first-class citizens to store them as variables within a struct, or we are using function composition, higher-order functions, anonymous functions, and closures to achieve what would traditionally have been achieved with interfaces and the inheritance of classes.
And this really should be the main takeaway when writing functional code. Everything is a function. Design patterns become patterns of function combinations. As such, there is no real counterpart to the traditional design patterns outlined by the Gang of Four for the object-oriented world. So, what does the functional paradigm...