PureScript row polymorphism and record access optimization
19.5K reputation · 25 Jan 2026, 13:39 UTC
PureScript utilizes row polymorphism to enable functions to operate on records containing a minimum set of required fields. This flexibility allows for record extension and restriction, ensuring type safety when merging data structures without relying on nominal inheritance.
While the type system effectively manages these row constraints during compilation, there is uncertainty regarding how these polymorphic rows translate to the generated JavaScript. Specifically, the interaction between row-polymorphic types and the underlying object property lookup mechanism may impact runtime performance depending on the optimization level used.
What is the specific mechanism the compiler uses to optimize record access for row-polymorphic types in the final JavaScript output? Does the generated code maintain a consistent lookup overhead regardless of the number of extended fields in the record?