Functors
摘要
To round out the previous chapter were discussions of algebras—Maybe, Either, and the promise. The said algebras, despite subtle differences in the manner of sterilization of error values, all further the agenda of composition via a map operation—effectively an “apply-to-all” rule that was, albeit in a slightly different context, discussed in Chapter 3. Because functors enable those who use them to map over encapsulated data, they can be viewed as connectors of abstract structures. In connecting structures via discretionary rules, functors make it possible to not only tidy away more elaborate data that need not be exposed except for when a function is to be applied, but also allow for the reuse of entire sets of combinable data and functions. This, Chapter 5 of the book, explores the connectivity of the functor. Among its notable offerings are discussions centered around embracing the algorithmic approaches inherent to functors, the logical system of Category Theory that operationalizes these approaches, and the applications of functors in everyday PHP code.