Table of Contents
Fetching ...

Handling Higher-Order Effectful Operations with Judgemental Monadic Laws

Zhixuan Yang, Nicolas Wu

TL;DR

The paper tackles the challenge of designing languages with higher-order effect handlers by introducing System Fha, a core calculus that treats handlers as carried by raw monads while computation judgments remain governed by monadic laws. It develops a rigorous semantic foundation using realizability and synthetic logical relations (STC) to establish canonicity and parametricity for the recursion-free fragment and extends to general recursion via synthetic domain theory. By leveraging a logical framework (LccLF) to encode System Fha and deploying Artin gluing among models, the authors obtain a consistent equational theory and a path to program extraction from well-typed terms. The work clarifies how to reconcile lawless monadic handling with judgmental monadic laws, enabling precise reasoning about higher-order effects and laying groundwork for future type-and-effect extensions and compiler optimizations.

Abstract

This paper studies the design of programming languages with handlers of higher-order effectful operations -- effectful operations that may take in computations as arguments or return computations as output. We present and analyse a core calculus with higher-kinded impredicative polymorphism, handlers of higher-order effectful operations, and optionally general recursion. The distinctive design choice of this calculus is that handlers are carried by lawless raw monads, while the computation judgements still satisfy the monadic laws judgementally. We present the calculus with a logical framework and give denotational models of the calculus using realizability semantics. We prove closed-term canonicity and parametricity for the recursion-free fragment of the language using synthetic Tait computability and a novel form of the $\top\top$-lifting technique.

Handling Higher-Order Effectful Operations with Judgemental Monadic Laws

TL;DR

The paper tackles the challenge of designing languages with higher-order effect handlers by introducing System Fha, a core calculus that treats handlers as carried by raw monads while computation judgments remain governed by monadic laws. It develops a rigorous semantic foundation using realizability and synthetic logical relations (STC) to establish canonicity and parametricity for the recursion-free fragment and extends to general recursion via synthetic domain theory. By leveraging a logical framework (LccLF) to encode System Fha and deploying Artin gluing among models, the authors obtain a consistent equational theory and a path to program extraction from well-typed terms. The work clarifies how to reconcile lawless monadic handling with judgmental monadic laws, enabling precise reasoning about higher-order effects and laying groundwork for future type-and-effect extensions and compiler optimizations.

Abstract

This paper studies the design of programming languages with handlers of higher-order effectful operations -- effectful operations that may take in computations as arguments or return computations as output. We present and analyse a core calculus with higher-kinded impredicative polymorphism, handlers of higher-order effectful operations, and optionally general recursion. The distinctive design choice of this calculus is that handlers are carried by lawless raw monads, while the computation judgements still satisfy the monadic laws judgementally. We present the calculus with a logical framework and give denotational models of the calculus using realizability semantics. We prove closed-term canonicity and parametricity for the recursion-free fragment of the language using synthetic Tait computability and a novel form of the -lifting technique.

Paper Structure

This paper contains 49 sections, 15 theorems, 179 equations, 1 figure.

Key Result

Theorem 2.18

Let $\mathscr{C}$ be an LCCC. The groupoid $\textnormal{\scshape LCCC}_{\cong}(\mathop{\textnormal{\scshape Jdg}}\text{\rmfamily F\textomega{ha}}, \mathscr{C})$ of LCC-functors and natural isomorphisms is equivalent to the groupoid of $\text{\rmfamily F\textomega{ha}}$-models in $\mathscr{C}$.

Figures (1)

  • Figure 1: Derived concepts in System F

Theorems & Definitions (42)

  • Example 2.3
  • Example 2.5
  • Example 2.6
  • Example 2.7
  • Example 2.8
  • Example 2.9
  • Remark 2.10
  • Remark 2.11
  • Remark 2.12
  • Remark 2.13
  • ...and 32 more