Skip to main content
QUICK REVIEW

[Paper Review] Pure Methods for roDOT

Martin Odersky, Aleksander Boruch-Gruszecki|arXiv (Cornell University)|Jul 7, 2022
Logic, programming, and type systemsComputer Science1 citations
TL;DR

This paper introduces CC<:□, a type system that tracks captured capabilities—such as effects or resources—within types to enable lightweight, polymorphic effect checking without explicit effect quantifiers. By representing captured variables in types and using subtyping and boxing to manage scope, the system supports pure function abstraction and effect polymorphism while minimizing syntactic overhead.

ABSTRACT

Object-oriented programming languages typically allow mutation of objects, but pure methods are common too. There is great interest in recognizing which methods are pure, because it eases analysis of program behavior and allows modifying the program without changing its behavior. The roDOT calculus is a formal calculus extending DOT with reference mutability. In this paper, we explore purity conditions in roDOT and pose a SEF guarantee, by which the type system guarantees that methods of certain types are side-effect free. We use the idea from ReIm to detect pure methods by argument types. Applying this idea to roDOT required just a few changes to the type system, but necessitated re-working a significant part of the soundness proof. In addition, we state a transformation guarantee, which states that in a roDOT program, calls to SEF methods can be safely reordered without changing the outcome of the program. We proved type soundness of the updated roDOT calculus, using multiple layers of typing judgments. We proved the SEF guarantee by applying the Immutability guarantee, and the transformation guarantee by applying the SEF guarantee within a framework for reasoning about safe transformations of roDOT programs. All proofs are mechanized in Coq.

Motivation & Objective

  • To address the lack of usability and flexibility in existing effect systems, particularly in handling polymorphism and code duplication.
  • To enable safe, fine-grained effect tracking by representing captured capabilities directly in types.
  • To eliminate the need for explicit effect quantifiers in higher-order functions by leveraging capabilities as first-class values.
  • To design a type system that supports effect polymorphism naturally through subtyping and scoping of captured variables.
  • To minimize notational overhead in practice by tracking only relevant variables and using subsumption and boxing to control capture set growth.

Proposed method

  • The system extends System F<: with dependent types over capture sets, where each type carries a set of free capability variables.
  • Functions are annotated with their free capability variables, ensuring that all effects are tracked through the type system.
  • Monadic normal form (MNF) is enforced to prevent non-variable terms in types, preserving type safety and scoping.
  • The avoidance property is enforced on let-bindings to prevent out-of-scope variables from appearing in types.
  • A rich subtyping system is defined over capture sets, incorporating both set inclusion and type compatibility to support subcapturing.
  • A box connective is introduced to encapsulate values and prevent propagation of capture information, reducing annotation bloat.

Experimental results

Research questions

  • RQ1Can captured capabilities be tracked in types in a way that supports polymorphic effect checking without explicit effect quantifiers?
  • RQ2How can scoping and lifetime of capabilities be modeled within a type system to prevent use-after-free and ensure safety?
  • RQ3What design principles minimize syntactic overhead while maintaining expressiveness and safety in effect tracking?
  • RQ4Can subtyping and subsumption over capture sets be used to reduce the need for detailed annotations?
  • RQ5How can boxing be used to control the growth of capture sets and avoid repetition in type annotations?

Key findings

  • The CC<:□ calculus supports effect polymorphism naturally, as functions do not need to be annotated with effect quantifiers; instead, required capabilities are inferred from argument types.
  • The system achieves lightweight effect checking by tracking only variables whose types have non-empty capture sets, reducing annotation burden.
  • Subcapturing and subsumption allow coarser capture sets to be used in place of more detailed ones, simplifying type annotations.
  • Boxing effectively isolates captured capabilities, preventing their propagation into outer types and significantly reducing annotation repetition.
  • The system is expressive enough to model common data structures and their usage patterns with intuitive, readable types.
  • The design enables practical capture checking in programming languages by providing a formal foundation for reasoning about capabilities and their scopes.

Read this paper

Open the full text in the Nubint reader and ask about any passage as you read.

Read this paper on Nubint

This review was generated by AI from the original paper. Please check the paper before citing it.