IT lexicon › Programming › Strictness analysis

Strictness analysis

Programming På svenska → Updated: 2026-11-07

The analysis that works out which arguments a function is guaranteed to evaluate, so a lazy language can compute them up front instead of wrapping them in thunks.

In a lazy language like Haskell, every argument becomes a thunk: a small heap object that computes the value only when someone asks for it. That is wasted effort when the value is always needed anyway. A function is strict in an argument if it diverges whenever the argument diverges, formally f ⊥ = ⊥. Then evaluating the argument early is safe — the program can't tell the difference, because it would have hung regardless.

Alan Mycroft formalised the idea in 1980 using abstract interpretation, and it became one of the technique's classic showcases. GHC runs a generalised version called demand analysis, which also tracks how deeply a value is used. On its own it saves a little; combined with the worker/wrapper transformation it lets GHC pass machine integers in registers instead of pointers into the heap. It will not, however, rescue a foldl that leaks memory beyond the optimizer's reach.

← Back to the lexicon