Summary
This chapter introduced HOF. We saw how we can generalize existing code by abstracting over function parameters and then reuse this generalization more widely. Next, we studied how this mechanism can be used to capture structural recursion in a reusable HOF. Then, we reviewed a range of commonly used predefined HOF and combined them to concisely solve tasks.
In Chapter 5, First-Class Functions, we will see how Haskell strongly encourages the use of HOFs with a range of language features that facilitate their use. In particular, they make it easy to write function parameters for HOFs and, more generally, write programs mostly in terms of functions, rather than in terms of the values they process.