Summary
In this chapter, we explained why Haskell needs an unusual approach toward I/O – namely, to reconcile I/O with lazy evaluation and the mathematical notion of functions, Haskell separates the tasks of describing I/O and performing it. A Haskell program assembles an I/O description out of primitive functions and the bind operator, (>>=)
, which is then performed by the runtime system. Writing I/O programs is facilitated by the imperative-style do notation and the availability of a convenient range of primitive I/O functions in the standard library.
Now that we have concluded our overview of the key functional programming and Haskell-specific language features, we will shift our focus to the more advanced programming patterns that are captured as reusable abstractions in the Haskell libraries. Chapter 9, Monoids and Foldables, introduces us to the first two abstractions – a generalization of lists to other collections whose content can also be processed in...