Table of Contents
Fetching ...

Contextual Metaprogramming for Session Types

Pedro Ângelo, Atsushi Igarashi, Yuito Murase, Vasco T. Vasconcelos

TL;DR

Contextual Metaprogramming for Session Types addresses integrating staged metaprogramming with session-typed concurrency. The authors develop a multilevel contextual modal linear lambda calculus that combines a box modality $\square\tau$ with contextual types $\overline\tau \vdash^{n} T$ and a linear/unrestricted resource system. They demonstrate how code fragments can be produced, transmitted via channels, and executed on demand, while preserving channel linearity and session protocols. A formal type system with context split and a type checker ensures typing judgments for terms and processes, and the accompanying proofs establish preservation and progress for a concurrent runtime. The work enables robust server-side code generation, distributed computation, and multi-tier metaprogramming with typed, deadlock-averse communication patterns.

Abstract

We propose the integration of staged metaprogramming into a session-typed message passing functional language. We build on a model of contextual modal type theory with multi-level contexts, where contextual values, closing arbitrary terms over a series of variables, may be boxed and transmitted in messages. Once received, one such value may then be unboxed and locally applied before being run. To motivate this integration, we present examples of real-world use cases, for which our system would be suitable, such as servers preparing and shipping code on demand via session typed messages. We present a type system that distinguishes linear (used exactly once) from unrestricted (used an unbounded number of times) resources, and further define a type checker, suitable for a concrete implementation. We show type preservation, a progress result for sequential computations and absence of runtime errors for the concurrent runtime environment, as well as the correctness of the type checker.

Contextual Metaprogramming for Session Types

TL;DR

Contextual Metaprogramming for Session Types addresses integrating staged metaprogramming with session-typed concurrency. The authors develop a multilevel contextual modal linear lambda calculus that combines a box modality with contextual types and a linear/unrestricted resource system. They demonstrate how code fragments can be produced, transmitted via channels, and executed on demand, while preserving channel linearity and session protocols. A formal type system with context split and a type checker ensures typing judgments for terms and processes, and the accompanying proofs establish preservation and progress for a concurrent runtime. The work enables robust server-side code generation, distributed computation, and multi-tier metaprogramming with typed, deadlock-averse communication patterns.

Abstract

We propose the integration of staged metaprogramming into a session-typed message passing functional language. We build on a model of contextual modal type theory with multi-level contexts, where contextual values, closing arbitrary terms over a series of variables, may be boxed and transmitted in messages. Once received, one such value may then be unboxed and locally applied before being run. To motivate this integration, we present examples of real-world use cases, for which our system would be suitable, such as servers preparing and shipping code on demand via session typed messages. We present a type system that distinguishes linear (used exactly once) from unrestricted (used an unbounded number of times) resources, and further define a type checker, suitable for a concrete implementation. We show type preservation, a progress result for sequential computations and absence of runtime errors for the concurrent runtime environment, as well as the correctness of the type checker.
Paper Structure (5 sections, 1 theorem, 4 equations, 12 figures)

This paper contains 5 sections, 1 theorem, 4 equations, 12 figures.

Key Result

lemma thmcounterlemma

$x:\tau \vdash \eta(x, \tau) : \tau$.

Figures (12)

  • Figure 1: Message sequence chart for the example
  • Figure 2: Message sequence chart for the example
  • Figure 3: Terms and processes
  • Figure 4: Term evaluation $M \rightarrow M$
  • Figure 5: Structural congruence ${P\ \equiv\ Q}$
  • ...and 7 more figures

Theorems & Definitions (1)

  • lemma thmcounterlemma