PLMay 8

First-Class Refinement Types for Scala

arXiv:2605.0836915.71 citations
Predicted impact top 70% in PL · last 90 daysOriginality Incremental advance
AI Analysis

For Scala developers and verification researchers, this work removes the disconnect between refinements and host language features, but the implementation is a prototype and the approach is incremental over existing refinement type systems.

This work introduces first-class refinement types for Scala 3, where refinements are ordinary types integrated with subtyping, inference, and pattern matching. The design is proven sound via a mechanized core calculus and implemented as a prototype compiler extension with an e-graph-based solver.

Refinement types -- types qualified with logical predicates -- have proven effective for lightweight verification in languages like Liquid Haskell, F*, and Dafny. However, in these systems refinements are either written in a separate specification language or treated as second-class annotations, disconnected from the host language's type system. This disconnect creates usability barriers: programmers must maintain two mental models, and refinements cannot interact with features like type inference, subtyping, or overloading. We present the design of first-class refinement types for Scala 3, where refinements are ordinary types that participate in subtyping, inference, and pattern matching alongside existing language features. We prove type soundness of a core calculus mechanized in Rocq, combining dependent function types, bounded polymorphism, positive equi-recursive types, union and intersection types, and refinement types under a partial-correctness semantics using a fuel-bounded definitional interpreter and semantic typing. Finally, we implement our design as a prototype extension of the Scala 3 compiler with a lightweight e-graph-based solver for predicate entailment.

Foundations

The foundational work for this paper's niche, ranked by how specifically the neighbourhood builds on it — not by global fame.

Your Notes