First-Class Functions
In the previous chapter, we studied higher-order functions (HOFs), one of the defining features of functional programming. This chapter explains how Haskell actively supports working with HOFs by providing a number of facilitating language features.
The ability of HOFs to abstract over functions means that they are more reusable than first-order functions. Indeed, often tasks can be concisely handled by assembling a number of predefined higher-order functions. Of course, HOFs are useless without the functions that we supply to them as parameters. Hence, part of the effectiveness of HOFs stems from being able to quickly and concisely supply the right function parameters to instantiate the HOFs.
In the previous chapter, we often did not have the right function at hand to supply as a parameter. Instead, we wrote a dedicated new function, often in the form of a local definition, to make up for this lack. Recall, for example, the isSpaceCharacter
function that...