Incremental Computation Graphs
Yabu's incremental computation graphs enable fast interactive type-checking and compilation of code. When a function is redefined, the system recompiles and parses the updated function definition, then constructs a runtime graph of dependent computations. These computations include parsing the source into an AST, type-checking the function, and generating compiled code.
The system leverages memoization to avoid redundant computations when the input hasn't changed. Each memoization entry stores the revision history of dependencies, allowing the system to detect when a dependency's revision has changed and invalidate dependent computations. For example, if a function's type signature changes, the typechecking of the entire function is automatically invalidated.
Memoized values include the :verified-at and :changed-at timestamps, which indicate when the value was last validated and when its dependencies were last updated. When a dependency's revision is less than the memoization's revision, the memoized value is considered outdated, and the system must recompute the dependent computations.
During the type-checking process, the system walks the dependency chain, updating the :verified-at timestamps for each memoized value as it progresses. This enables the system to quickly determine whether a computation needs to be re-executed or can be short-circuited using already validated memoized values. The Yabu incremental typechecker is designed to be highly efficient, even for large programs, by utilizing this incremental computation graph approach.
Written by urgent.news from Lobsters's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.