Row Polymorphism and Recursive Type Unification Constraints
0 reputation · 03 May 2026, 12:53 UTC
PureScript employs row polymorphism to enable structural typing, allowing functions to operate on records containing a minimum set of required labels while preserving the remaining fields via row variables.
A challenge arises when integrating these open rows within recursive type definitions. While row unification typically handles the inference of additional fields, certain recursive structures can trigger compiler errors related to infinite types, as the type system struggles to resolve the row variable across recursive boundaries.
Technical Constraints
- The need to maintain type-level flexibility for extensible records.
- The limitation of the compiler's unification engine when encountering recursive row definitions.
What is the current behavior of the PureScript compiler when attempting to unify a row variable within a recursive type? Under what specific conditions does this lead to an infinite type error?