Skip to main content
QUICK REVIEW

[Paper Review] Handling Exceptions and Effects with Automatic Resource Analysis

Ethan D. Chu, Yiyang Guo|arXiv (Cornell University)|Feb 28, 2026
Logic, programming, and type systemsComputer Science0 citations
TL;DR

The paper presents the first automatic resource bound analysis that supports non-local control transfer via exception and effect handlers, extending AARA with a soundness proof and implementing it for Standard ML with experimental evaluation.

ABSTRACT

There exist many techniques for automatically deriving parametric resource (or cost) bounds by analyzing the source code of a program. These techniques work effectively for a large class of programs and language features. However, non-local transfer of control as needed for exception or effect handlers has remained a challenge. This paper presents the first automatic resource bound analysis that supports non-local control transfer between exceptions or effects and their handlers. The analysis is an extension of type-based automatic amortized resource analysis (AARA), which automates the potential method of amortized analysis. It is presented for a simple functional language with lists and linear potential functions. However, the ideas are directly applicable to richer settings and implemented for Standard ML and polynomial potential functions. Apart from the new type system for exceptions and effects, a main contribution is a novel syntactic type-soundness theorem that establishes the correctness of the derived bounds with respect to a stack-based abstract machine. An experimental evaluation shows that the new analysis is capable of analyzing programs that cannot be analyzed by existing methods and that the efficiency overhead of supporting exception and effect handlers is low.

Motivation & Objective

  • Extend automatic amortized resource analysis (AARA) to handle non-local control transfer via exceptions and effect handlers.
  • Develop a type system with resource annotations that accounts for bound costs of exception and effect handling.
  • Provide a formal soundness proof relating the type-derived bounds to a stack-based abstract machine.
  • Implement the approach for Standard ML and evaluate its effectiveness and efficiency on benchmarks.

Proposed method

  • Extend AARA with typing rules for exceptions and effects and their handlers.
  • Introduce a novel small-step soundness proof using a stack-based abstract machine and modal separation of values and expressions.
  • Use a tick-based cost model to represent resource usage and ensure handler costs are bounded by payloads.
  • Model exception and effect payloads as contracts that carry potential used by handlers, enabling resource polymorphism.
  • Demonstrate typing for examples where non-local control transfer affects resource usage, including one-shot continuations for delimited continuations.
  • Implement the analysis on Standard ML via MLton and evaluate on benchmarks involving exceptions and effects.

Experimental results

Research questions

  • RQ1How can AARA be extended to automatically bound resources when exceptions and effect handlers transfer non-locally across functions?
  • RQ2What typing rules and potentials are needed to correctly account for costs at exception and effect handler sites?
  • RQ3Can the derived bounds be proven sound with respect to a stack-based abstract machine that models continuations and delimited control?
  • RQ4What is the performance impact and bound precision of the new analysis in practice on real-world like SML programs with exceptions and effects?

Key findings

  • The work provides the first resource bound analysis that fully supports exception handlers and inter-function exception transfer.
  • A novel syntactic soundness proof is given, based on a stack-based abstract machine and a modal value/expressions separation.
  • The analysis derives tight bounds by associating potentials with exception and effect payloads, enabling precise accounting of handler costs.
  • Experimental evaluation shows the method analyzes programs that are beyond the reach of prior techniques and incurs low overhead.
  • The implementation for Standard ML demonstrates effectiveness on benchmarks that use exceptions and effects, including cases not analyzable by existing methods.

Read this paper

Open the full text in the Nubint reader and ask about any passage as you read.

Read this paper on Nubint

This review was generated by AI from the original paper. Please check the paper before citing it.