In the last lecture, we introduced the concept of higher-order functions, which are functions which can take in other functions as parameters or return functions as values. In this lecture, we expanded on that notion with additional applications of higher-order functions.
Most importantly, we addressed the concept of staging, which is the practice of deliberately placing computations with respect to curried arguments. Writing code in such a way can avoid unnecessary data dependencies, as well as yield performance benefits when dealing with work that can be logically separated from later arguments. We will see later in the course that it will be particularly important when we start adding effects into the SML language.
We also looked more generically at HOFs on other data structures, such as trees. Similarly to how lists admit a folding function, trees also allow us to write functions like treemap and treefold.
We also provided an initial look at monads, in particular, the option bind, which lets us write code that potentially produces options in an extremely terse way, bypassing the need for boilerplate casing.
Slides