CHAPTER 5

image

Laziness and Infinite Structures

In the previous chapters I have introduced several of the pillars of Haskell programming: the pure functional paradigm, and the strongly typed nature of the language, which nevertheless allows powerful type constructs such as parametric polymorphism and type classes. This chapter will be devoted to understand the unique evaluation model of Haskell, based on laziness, and the consequences derived from that choice.

In short, lazy evaluation means that only the necessary parts of an expression are computed, and this is done at the very last possible moment. For example, if you have an expression such as ...

Get Beginning Haskell: A Project-Based Approach now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.