The Incomplete Guide to Lazy Evaluation (in Haskell)
Originally, I wanted to write a complete guide to lazy
evaluation, but then.
Lazy evaluation is the most widely used method for executing Haskell
program code on a computer. It determines the time and memory usage of
Haskell programs, and it allows new and powerful ways to write modular
code. To make full use of purely functional programming, a good
understanding of lazy evaluation is very helpful.
The following series of tutorials provide a thorough introduction to
this topic:
- How does Lazy Evaluation Work in
Haskell? — Start here. This tutorial explains how expressions are
evaluated using lazy evaluation, and what that means for time and memory
usage.
- Writing More Modular Code with
Lazy Evaluation — Why use lazy evaluation in the first place? This
tutorial explains the power of lazy evaluation and how it can help us to
write clear and modular code. In particular, it will tell you about
infinite lists.
- Non-Strict Semantics of Haskell
– What Exactly does Lazy Evaluation Calculate? – This tutorial
explains that we actually do not need to know how lazy
evaluation works in order to understand what a Haskell program
calculates, thanks to a concept called denotational
semantics. We cover the important notion of a
strict function, which shows up in many discussions
about optimizing Haskell programs. Lazy evaluation controls the
how, but not the what of a Haskell program.
Additionally, tools for reasoning about space and time usage are
provided in the following articles: