Haskell's TCO Mechanism: Thunks & Strictness Analysis

Haskell's Glasgow Haskell Compiler (GHC) achieves Tail Call Optimization (TCO) by transforming tail calls into jumps, preventing stack growth. This is possible even with lazy evaluation because GHC uses 'strictness analysis' to determine when an argument will always be evaluated, allowing it to avoid creating unnecessary 'thunks' (unevaluated expressions) and directly pass unboxed values.

Sources

Open the full topic