Lune

POPL2024顶会

Answer Refinement Modification: Refinement Type System for Algebraic Effects and Handlers

Fuga Kawamata, Hiroshi Unno, Taro Sekiyama, Tachio Terauchi

摘要

Algebraic effects and handlers are a mechanism to structure programs with computational effects in a modular way. They are recently gaining popularity and being adopted in practical languages, such as OCaml. Meanwhile, there has been substantial progress in program verification via refinement type systems . While a variety of refinement type systems have been proposed, thus far there has not been a satisfactory refinement type system for algebraic effects and handlers. In this paper, we fill the void by proposing a novel refinement type system for languages with algebraic effects and handlers. The expressivity and usefulness of algebraic effects and handlers come from their ability to manipulate delimited continuations , but delimited continuations also complicate programs' control flow and make their verification harder. To address the complexity, we introduce a novel concept that we call answer refinement modification (ARM for short), which allows the refinement type system to precisely track what effects occur and in what order when a program is executed, and reflect such information as modifications to the refinements in the types of delimited continuations. We formalize our type system that supports ARM (as well as answer type modification, or ATM) and prove its soundness. Additionally, as a proof of concept, we have extended the refinement type system to a subset of OCaml 5 which comes with a built-in support for effect handlers, implemented a type checking and inference algorithm for the extension, and evaluated it on a number of benchmark programs that use algebraic effects and handlers. The evaluation demonstrates that ARM is conceptually simple and practically useful. Finally, a natural alternative to directly reasoning about a program with delimited continuations is to apply a continuation passing style (CPS) transformation that transforms the program to a pure program without delimited continuations. We investigate this alternative in the paper, and show that the approach is indeed possible by proposing a novel CPS transformation for algebraic effects and handlers that enjoys bidirectional (refinement-)type-preservation. We show that there are pros and cons with this approach, namely, while one can use an existing refinement type checking and inference algorithm that can only (directly) handle pure programs, there are issues such as needing type annotations in source programs and making the inferred types less informative to a user.

问 Lune

几分钟读透这篇 Paper,不用再花一下午。

Lune 能读完全文,也能读引用它的顶会 Paper,讲清它的结论、证据和局限,每一点都注明出自哪篇 Paper。不用硬啃,也不靠猜。

已有 5 篇顶会 Paper 引用了它。别等审稿人问起,先弄清它们发现了什么。

可以从这些问题问起

Lune 可以查阅

全文 · 引用它的顶会 Paper · 相关的 Paper

获取答案

免费开始,无需绑卡

脉络

  • Abstract Interpretation of Temporal Safety Effects of Higher Order Programs 引用了 Temporal Verification with Answer-Effect Modification: Dependent Temporal Type-and-Effect System with Delimited Continuations
  • Retrofitting effect handlers onto OCaml 引用了 Binders by day, labels by night: effect instances via lexically scoped handlers
  • On Higher-Order Model Checking of Effectful Answer-Type-Polymorphic Programs 引用了 Retrofitting effect handlers onto OCaml
  • On Higher-Order Model Checking of Effectful Answer-Type-Polymorphic Programs 引用了 Temporal Verification with Answer-Effect Modification: Dependent Temporal Type-and-Effect System with Delimited Continuations
  • On Higher-Order Model Checking of Effectful Answer-Type-Polymorphic Programs 引用了 Higher-Order Model Checking of Effect-Handling Programs with Answer-Type Modification
  • On Higher-Order Model Checking of Effectful Answer-Type-Polymorphic Programs 引用了 Binders by day, labels by night: effect instances via lexically scoped handlers
  • Thrust: A Prophecy-Based Refinement Type System for Rust 引用了 Temporal Verification with Answer-Effect Modification: Dependent Temporal Type-and-Effect System with Delimited Continuations
  • Thrust: A Prophecy-Based Refinement Type System for Rust 引用了 Constraint-Based Relational Verification
  • Handling Exceptions and Effects with Automatic Resource Analysis 引用了 Retrofitting effect handlers onto OCaml
  • Handling Exceptions and Effects with Automatic Resource Analysis 引用了 Temporal Verification with Answer-Effect Modification: Dependent Temporal Type-and-Effect System with Delimited Continuations
  • Higher-Order Model Checking of Effect-Handling Programs with Answer-Type Modification 引用了 Temporal Verification with Answer-Effect Modification: Dependent Temporal Type-and-Effect System with Delimited Continuations
它引用的引用它的从左到右按年份排列,引用越多,位置越高。

引用它的顶会 Paper5

  1. Higher-Order Model Checking of Effect-Handling Programs with Answer-Type ModificationTaro Sekiyama, Hiroshi UnnoOOPSLA 2024 · 4 次引用
  2. Abstract Interpretation of Temporal Safety Effects of Higher Order ProgramsMihai Nicola, Chaitanya Agarwal, Eric Koskinen, Thomas WiesOOPSLA 2025 · 1 次引用
  3. On Higher-Order Model Checking of Effectful Answer-Type-Polymorphic ProgramsTaro Sekiyama, Ugo Dal Lago, Hiroshi UnnoOOPSLA 2025
  4. Thrust: A Prophecy-Based Refinement Type System for RustHiromi Ogawa, Taro Sekiyama, Hiroshi UnnoPLDI 2025
  5. Handling Exceptions and Effects with Automatic Resource AnalysisEthan Chu, Yiyang Guo, Jan HoffmannOOPSLA 2026

它引用的 Paper4

  1. Retrofitting effect handlers onto OCamlK. C. Sivaramakrishnan, Stephen Dolan, Leo White, Tom Kelly 等PLDI 2021 · 56 次引用
  2. Constraint-Based Relational VerificationHiroshi Unno, Tachio Terauchi, Eric KoskinenCAV 2021 · 47 次引用
  3. Binders by day, labels by night: effect instances via lexically scoped handlersDariusz Biernacki, Maciej Piróg, Piotr Polesiuk, Filip SieczkowskiPOPL 2020 · 46 次引用
  4. Temporal Verification with Answer-Effect Modification: Dependent Temporal Type-and-Effect System with Delimited ContinuationsTaro Sekiyama, Hiroshi UnnoPOPL 2023 · 15 次引用

相关 Paper

  1. Efficient compilation of algebraic effect handlersGeorgios Karachalias, Filip Koprivec, Matija Pretnar, Tom SchrijversOOPSLA 2021 · 9 次引用
  2. Affect: An Affine Type and Effect SystemOrpheas van Rooij, Robbert KrebbersPOPL 2025 · 7 次引用
  3. Hefty Algebras: Modular Elaboration of Higher-Order Algebraic EffectsCasper Bach Poulsen, Cas van der RestPOPL 2023 · 9 次引用
  4. A typed continuation-passing translation for lexical effect handlersPhilipp Schuster, Jonathan Immanuel Brachthäuser, Marius Müller, Klaus OstermannPLDI 2022 · 10 次引用
  5. Handling bidirectional control flowYizhou Zhang, Guido Salvaneschi, Andrew C. MyersOOPSLA 2020 · 12 次引用
黄昏的海面,两侧是细线勾勒的悬崖