Table of Contents
Fetching ...

Local Type Inference for Context-Free Session Types

Bernardo Almeida, Andreia Mordido, Vasco T. Vasconcelos

TL;DR

This work tackles local type inference for FreeST, a System F–based language with context-free session types, where impredicative polymorphism and a sequential composition operator complicate type checking. It introduces a bidirectional typing framework augmented with a novel type matching algorithm that uses type reduction and explicit tracking of mu-redexes to handle the monoidal laws and left-absorbing elements of context-free session types. The authors provide a complete algorithm, a prototype integrated into the FreeST compiler, and an evaluation showing successful reconstruction of type information without most type annotations on a large codebase. The results demonstrate improved usability by eliminating many type annotations and lay groundwork for formal termination and correctness proofs, with future extensions toward deadlock-freedom via priority annotations. This work advances practical type inference for expressive session-typed languages built on System F.

Abstract

We address the problem of local type inference for a language based on System F with context-free session types. We present an algorithm that leverages the bidirectional type checking approach to propagate type information, enabling first class polymorphism while addressing the intricacies brought about by the sequential composition operator and type equivalence. The algorithm improves the language's usability by eliminating the need for type annotations at type application sites.

Local Type Inference for Context-Free Session Types

TL;DR

This work tackles local type inference for FreeST, a System F–based language with context-free session types, where impredicative polymorphism and a sequential composition operator complicate type checking. It introduces a bidirectional typing framework augmented with a novel type matching algorithm that uses type reduction and explicit tracking of mu-redexes to handle the monoidal laws and left-absorbing elements of context-free session types. The authors provide a complete algorithm, a prototype integrated into the FreeST compiler, and an evaluation showing successful reconstruction of type information without most type annotations on a large codebase. The results demonstrate improved usability by eliminating many type annotations and lay groundwork for formal termination and correctness proofs, with future extensions toward deadlock-freedom via priority annotations. This work advances practical type inference for expressive session-typed languages built on System F.

Abstract

We address the problem of local type inference for a language based on System F with context-free session types. We present an algorithm that leverages the bidirectional type checking approach to propagate type information, enabling first class polymorphism while addressing the intricacies brought about by the sequential composition operator and type equivalence. The algorithm improves the language's usability by eliminating the need for type annotations at type application sites.

Paper Structure

This paper contains 7 sections, 6 equations, 5 figures.

Figures (5)

  • Figure 1: Syntax of types and expressions
  • Figure 2: Type reduction and $\mu$-redexes
  • Figure 3: Type matching
  • Figure 4: Running the match algorithm on types ${\color{RoyalBlue}{\mu{{\color{RoyalBlue}{{\color{RoyalBlue}{\alpha}}}}}.{{\color{RoyalBlue}{({\color{RoyalBlue}{{({\color{RoyalBlue}{{{{\color{RoyalBlue}{!}}}\,{\color{RoyalBlue}{{\color{RoyalBlue}{\mathsf{Int}}}}}};{{\color{RoyalBlue}{\alpha}}}}})};{{\color{RoyalBlue}{X}}}}})}}}}}$ and ${\color{RoyalBlue}{\mu{{\color{RoyalBlue}{{\color{RoyalBlue}{\beta}}}}}.{{\color{RoyalBlue}{({\color{RoyalBlue}{{{{\color{RoyalBlue}{!}}}\,{\color{RoyalBlue}{{\color{RoyalBlue}{\mathsf{Int}}}}}};{{\color{RoyalBlue}{\beta}}}}})}}}}}$
  • Figure 5: Bidirectional typing