arXiv:2610.26266cs.PLOct 2026

Manuscript Offprint

arXiv:2610.26266

Polarized Scheme: duality of computation, delimited control, and continuation-passing macro Interleaving

Christopher Dutchyn

Open access. PaperVantage converted this article to text, so layout and figures may differ from the original. This text is shared under the same licence.

Abstract

Static type systems for Scheme have traditionally followed one of two paths: manifest type checking with multi-dispatch (Clifton and Leavens, 2005) or latent occurrence typing tailored for untyped interoperation (Tobin-Hochstadt and Felleisen, 2008). In this paper, we propose Polarized Scheme, a static foundation founded upon polarized type theory and the duality of computation. In Polarized Scheme, values are positive data producers ( A+A^{+}) and continuations are negative observation consumers ( ∼A+\sim A^{+}). Functions operate symmetrically under dual viewpoints: as forward value-transformers and as backward continuation-transformers. Computation exists exclusively at the interaction cut ⟨P∣K⟩\langle P \mid K \rangle executed on a focus-and-context abstract machine separating positive data focus from negative return contexts ( R\mathcal{R}). Delimited control (shift/reset) and continuation marks are expressed directly as Return Stack frame operations parameterized by the prompt's ambient answer type without polluting producer data types. Furthermore, we formalize the hygienic macro system as an interleaved continuation-passing pipeline, where macro expansion erects its own continuation hierarchy nesting into runtime evaluation. We prove Subject Reduction, Progress with respect to prompt-delimited stacks, and Duality Bisimilarity, characterize Return Stack reclamation for dynamic closures, and report on an executable reference implementation in VeGo with a verified cut-elimination dispatcher.

1 Introduction

The design of static type systems for dynamic languages like Scheme has historically focused on accommodating untyped idioms. Clifton and Leavens [2] introduced multi-dispatch annotations, while Tobin-Hochstadt and Felleisen [12] established Typed Racket based on occurrence typing and latent predicate refinement.

However, Scheme possesses a deeper foundational characteristic: first-class control. Continuations in Scheme are first-class entities that reify evaluation contexts into values. In standard type systems, continuations are forced into the value category ((cont τ\tau) or τ→⊥\tau \to \bot), obscuring the fundamental asymmetry between data that is produced and computations that consume.

Drawing from polarized linear logic [7], Call-by-Push-Value (CBPV) [8], and the classical duality of computation [3, 5], we formulate Polarized Scheme. Our system establishes a strict structural divide:

  1. Positive Data Producers ( A+A^{+}): Discrete values, constructors (units, booleans, integers, pairs, sum injections, and suspended thunks) that construct data.

  2. Negative Observation Consumers ( N−N^{-}): Evaluation contexts, continuations, and elimination destructors ( ∼A+\sim A^{+}, projections, branching cases, function applications, thunk force) that consume data.

  3. Dual Function Viewpoints: Functions ↓(A+→∼B+)\downarrow(A^{+} \rightarrow \sim B^{+}) act simultaneously as forward value-transformers (consuming an input value to produce an answer) and backward continuation-transformers (transforming a continuation awaiting B+B^{+} into one awaiting A+A^{+}).

  4. The Focus-and-Context Abstract Machine: Execution is formalized as polarized cut elimination on two distinct structures: an active producer focus P and a Return Stack R of negative consumers.

  5. Interleaved Continuation-Passing Macros: Rather than an isolated pre-processing pass, macro expansion is an interleaved pipeline where macro invocations erect their own continuation hierarchy that nests into evaluation.