Summary
This chapter introduced a number of language features that facilitate the creation of new functions out of existing ones, which is particularly useful when working with higher-order functions. Three of these features originate in the lambda calculus – anonymous functions, currying, and eta reduction. The fourth feature, function composition, is a common operator used in mathematics. Function composition and eta reduction both promote the point-free programming style that focuses on functions, rather than on the values they process. Finally, to illustrate the first-class nature of functions, we saw how they can be used to represent data structures.
In Chapter 6, Type Classes, we will learn about Haskell’s mechanism for overloading functions called type classes. While we expect that predefined operators such as (+)
and (<)
work for different built-in types, type classes also allow us to define these operators for our own algebraic data types. Moreover, with...