Type-Level Computations for Ruby Libraries
Milod Kazerounian, Sankha Narayan Guria, Niki Vazou, Jeffrey S., Foster, David Van Horn

TL;DR
CompRDL introduces type-level computations for Ruby, enabling more precise static type checking of dynamic features like database schemas and reducing manual casts, with proven soundness and practical effectiveness.
Contribution
It presents a novel type system for Ruby that incorporates type-level computations, formalizes it, and demonstrates its practical utility in real-world applications.
Findings
Successfully type checked 132 methods across multiple Ruby programs.
Enabled more expressive property verification with fewer casts.
Discovered two type errors and one documentation error.
Abstract
Many researchers have explored ways to bring static typing to dynamic languages. However, to date, such systems are not precise enough when types depend on values, which often arises when using certain Ruby libraries. For example, the type safety of a database query in Ruby on Rails depends on the table and column names used in the query. To address this issue, we introduce CompRDL, a type system for Ruby that allows library method type signatures to include type-level computations (or comp types for short). Combined with singleton types for table and column names, comp types let us give database query methods type signatures that compute a table's schema to yield very precise type information. Comp types for hash, array, and string libraries can also increase precision and thereby reduce the need for type casts. We formalize CompRDL and prove its type system sound. Rather than type…
Peer Reviews
No public reviews on file for this paper yet. If you reviewed it on a platform where reviews are public (OpenReview, ICLR, NeurIPS, ICML), you can paste yours below so the community can read it here.
Videos
No videos yet. Explain this paper in a talk, walkthrough, or lecture? Add one.
