7
Lazy Evaluation
So far, we have not paid much attention to how Haskell programs are evaluated. Perhaps you have not seen anything out of the ordinary, but then we have really only scratched the surface. When we dig a little deeper, it turns out that Haskell’s evaluation strategy is quite different from that of other languages.
While other languages eagerly evaluate the program, Haskell has a much lazier attitude. Why should it do any work when it’s not clear that work is actually necessary? That’s why Haskell puts off evaluating any part of the program until it becomes clear that no result can be produced without doing that work.
This chapter gives a good idea of how evaluation works and why there is room for different strategies. It briefly ...
Get Soar with Haskell now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.