Papers
Topics
Authors
Recent
Search
2000 character limit reached

Answer Type Modification (ATM)

Updated 8 July 2026
  • Answer Type Modification (ATM) is a type system discipline that tracks changes in computation answer types during evaluation and control flow transitions.
  • ATM plays a central role in typed delimited continuations and effect handlers, enabling shift/reset operators and CPS translations that transform answer contexts.
  • ATM increases expressiveness by allowing distinct answer types in different clauses while supporting rigorous verification, soundness proofs, and termination guarantees.

Searching arXiv for recent and foundational papers on answer-type modification and related effect-handler work. I’ll look up relevant arXiv records to ground the article. Answer-type modification (ATM) is the ability of a type system to track that the answer type of a computation changes during evaluation. In typed delimited control, this is expressed by judgments of the form Γe:τ  ;  α,β\Gamma \vdash e : \tau \;;\; \alpha,\beta, meaning that under an initial answer type α\alpha, evaluating ee produces a value of type τ\tau and modifies the answer type to β\beta; in algebraic effects and handlers, the same idea is internalized as answer-type annotations on computation types and control effects (Kobori et al., 2016). ATM is central to the typing of delimited continuations, shift/reset-style operators, and effect handlers because captured continuations can suspend, resume, discard, duplicate, or recontextualize computations in ways that alter the type expected by the enclosing context. More recent work further refines ATM into answer-refinement modification (ARM), where only refinements change while the underlying base type remains fixed, and answer-effect modification (AEM), where temporal effects rather than ordinary result types are modified (Kawamata et al., 2023).

1. Core definition and formal role

In the surface calculus for typed delimited-control operators shift\mathsf{shift} and reset\mathsf{reset}, ATM is introduced by replacing the ordinary judgment Γe:τ\Gamma \vdash e : \tau with Γe:τ  ;  α,β\Gamma \vdash e : \tau \;;\; \alpha,\beta. The intended meaning is explicit: evaluation starts in an ambient answer type α\alpha and ends in an answer type α\alpha0. This is the sense in which ATM “modifies” answers rather than merely returning values. The same paper gives the effectful function type α\alpha1, meaning a function that takes a α\alpha2 and, under answer type α\alpha3, returns a α\alpha4 while changing the answer type to α\alpha5 (Kobori et al., 2016).

In effect-handler calculi, ATM is encoded directly in computation types. One formulation uses α\alpha6, where α\alpha7 is a pure computation returning α\alpha8, and α\alpha9 is an effectful computation that changes its answer type from ee0 to ee1. Another formulation packages the same information as a control effect

ee2

where ee3 means “no operation,” and ee4 means that when the computation is plugged into a context expecting answer type ee5, with ee6 bound to the computation’s result, the handler will see answer type ee7 (Endo et al., 18 Aug 2025).

ATM is therefore not merely a property of operators such as ee8 or of a specific handler clause. It is a typing discipline for the interaction between a computation and its surrounding context. This suggests that ATM is best understood as a structured account of context transformation: the program does not simply produce a value, but changes what the rest of the computation is allowed or required to be.

2. Typing judgments, subtyping, and handler interaction

A recurring feature of ATM systems is that computation types carry both a return component and an answer-type transformation. In the effect-handler setting, the judgment

ee9

assigns to a computation a type τ\tau0 that may be pure or may carry an annotation τ\tau1. In the refinement-based system for OCaml-5-style algebraic effects, the corresponding judgment is

τ\tau2

where τ\tau3 is an operation signature, τ\tau4 is a return type, and τ\tau5 is a control effect. The operation rule has the form

τ\tau6

which makes ATM visible already at the point of invoking an effectful operation (Kawamata et al., 2023).

Subtyping is the technical device that allows ATM to compose. In the finitary PCF system, the key rules include:

  • τ\tau7: τ\tau8.
  • τ\tau9: β\beta0, β\beta1, and β\beta2 imply β\beta3.
  • β\beta4: β\beta5 and β\beta6 imply β\beta7.

The last rule is especially important because it says that any pure computation may be viewed as an effectful one, provided subtyping holds on results and answer types. In the refinement formulation, the corresponding embedding rule is

β\beta8

and the core ATM subtyping rule weakens assumptions contravariantly and guarantees covariantly on answer types (Endo et al., 18 Aug 2025).

Handler typing is where ATM departs most sharply from no-ATM systems. Under a standard no-ATM system, every clause of a handler—both the return clause and each op-clause—must produce the same answer type. ATM frees the typing discipline from that requirement. In the finitary PCF account, each operation β\beta9 may have its own answer type shift\mathsf{shift}0, and the with-handle construct itself may modify the ambient answer type from shift\mathsf{shift}1 to shift\mathsf{shift}2. In the refinement system, a handler transforms a computation typed as shift\mathsf{shift}3 into shift\mathsf{shift}4 once the return clause is checked at shift\mathsf{shift}5 and each operation clause is checked against its own continuation type (Kawamata et al., 2023).

3. ATM in algebraic effects, handlers, and refinement typing

The refinement-type system for algebraic effects and handlers was proposed to address what the paper describes as the absence of a satisfactory refinement type system for algebraic effects and handlers. Its central claim is that the expressivity and usefulness of algebraic effects and handlers come from their ability to manipulate delimited continuations, but those same continuations complicate control flow and make verification harder. The proposed solution is ARM, a notion that allows the refinement type system to precisely track what effects occur and in what order when a program is executed, and to reflect such information as modifications to the refinements in the types of delimited continuations (Kawamata et al., 2023).

The distinction between ATM and ARM is explicit. Full ATM allows the entire answer type shift\mathsf{shift}6 of a computation to change. ARM is the restricted case where only the refinement part of a base-type answer changes and the underlying base type itself remains the same. The paper states that the system supports full ATM, but that in “ordinary” verification style one typically only needs ARM, namely the case where shift\mathsf{shift}7 and shift\mathsf{shift}8 have the same base type but different refinements.

A worked OCaml-5 example, “choose-max,” shows how ATM is used to verify a nondeterministic program:

α\alpha16

The account states that every call perform decide() has a type of the form shift\mathsf{shift}9, where reset\mathsf{reset}0 and reset\mathsf{reset}1 are refinement types selected by the predicate argument reset\mathsf{reset}2. For the first call, the instantiation

reset\mathsf{reset}3

and

reset\mathsf{reset}4

permits ATM subtyping via reset\mathsf{reset}5 to match the handler’s demands, yielding the whole program type reset\mathsf{reset}6. The paper emphasizes that every movement of the answer type from reset\mathsf{reset}7 to reset\mathsf{reset}8 is recorded by ATM as a whole computation-type change, even though only the refinement changes.

This use of ATM supports an interpretation of handlers as refinement transformers rather than only control delimiters. That interpretation is not stated verbatim, but it is a plausible implication of the way answer-type changes are reflected into continuation types.

4. CPS and prompt-passing translations

A major line of work on ATM studies whether ATM can be eliminated by translation into calculi or host languages without native answer-type modification. One result is a typed prompt-passing-style translation from a calculus with reset\mathsf{reset}9 and Γe:τ\Gamma \vdash e : \tau0 with ATM into a target calculus with multi-prompt Γe:τ\Gamma \vdash e : \tau1 and Γe:τ\Gamma \vdash e : \tau2 but no ATM. The translation maps

Γe:τ\Gamma \vdash e : \tau3

and

Γe:τ\Gamma \vdash e : \tau4

It creates two fresh prompts at each source-level reset, with one prompt corresponding to the new answer type after the reset and the other to the old one. The paper proves that the translation preserves typing and gives an optimized translation that generates prompts only when needed (Kobori et al., 2016).

The same elimination idea reappears for algebraic effects and handlers in CPS form. In the ATM-typable finitary PCF setting, types are translated by

Γe:τ\Gamma \vdash e : \tau5

Γe:τ\Gamma \vdash e : \tau6

Here Γe:τ\Gamma \vdash e : \tau7 is a record type encoding the operation signature. Operation invocation becomes record lookup and direct call, and withhandle constructs are compiled by supplying a record of handler bodies together with the continuation for the previous answer type. The paper describes this CPS as derivation-directed: each subtyping or typing derivation is turned into a target term (Endo et al., 18 Aug 2025).

The refinement-type paper for algebraic effects and handlers also proves bidirectional refinement-type preservation for its CPS transformation. The statements are:

  • Forward preservation: if Γe:τ\Gamma \vdash e : \tau8 then Γe:τ\Gamma \vdash e : \tau9.
  • Backward preservation: if Γe:τ  ;  α,β\Gamma \vdash e : \tau \;;\; \alpha,\beta0 in the handler-free target system, then there is some Γe:τ  ;  α,β\Gamma \vdash e : \tau \;;\; \alpha,\beta1 in the source such that Γe:τ  ;  α,β\Gamma \vdash e : \tau \;;\; \alpha,\beta2 and Γe:τ  ;  α,β\Gamma \vdash e : \tau \;;\; \alpha,\beta3.
  • Simulation: Γe:τ  ;  α,β\Gamma \vdash e : \tau \;;\; \alpha,\beta4.

These results show that ATM is not only a source-language typing discipline; it can also serve as a guide for semantics-preserving translations to handler-free or no-ATM targets. The data additionally states that the 2016 prompt-passing work generalizes Kiselyov’s direct-style implementation of typed printf, which uses two prompts to emulate the modification of answer types.

5. Verification, soundness, decidability, and termination

ATM has been used as a verification mechanism, not only as a typing convenience. In the refinement system for algebraic effects and handlers, the main meta-theoretic result is type safety in the form of subject-reduction and progress: if Γe:τ  ;  α,β\Gamma \vdash e : \tau \;;\; \alpha,\beta5 and Γe:τ  ;  α,β\Gamma \vdash e : \tau \;;\; \alpha,\beta6, then either Γe:τ  ;  α,β\Gamma \vdash e : \tau \;;\; \alpha,\beta7 with Γe:τ  ;  α,β\Gamma \vdash e : \tau \;;\; \alpha,\beta8, or Γe:τ  ;  α,β\Gamma \vdash e : \tau \;;\; \alpha,\beta9 for some α\alpha0, or α\alpha1 can step further. The proof sketch uses standard induction on evaluation together with α\alpha2 to justify contravariant and covariant manipulations of answer types (Kawamata et al., 2023).

In temporal verification, the corresponding notion is answer-effect modification rather than answer-type modification. The system extends temporal effects to shiftα\alpha3/resetα\alpha4 by giving computations a temporal effect α\alpha5 together with a control effect α\alpha6, written

α\alpha7

The control effect is either α\alpha8 or α\alpha9. The key interpretation is that α\alpha00 records what the captured continuation’s context must satisfy, while α\alpha01 records what the enclosing resetα\alpha02 expects. The paper proves soundness for finite event sequences via type safety and for infinite event sequences using a logical relation, and emphasizes that AEM enables reasoning about traces yielded by captured continuations (Sekiyama et al., 2022).

A different consequence of ATM appears in finitary PCF with effect handlers. The paper proves the theorem: if α\alpha03 is a closed ATM-typable finitary PCF program with effect handlers, then deciding whether α\alpha04 holds is decidable. The proof proceeds by CPS-transforming α\alpha05 into a simply-typed, handler-free finitary PCF program α\alpha06, using typability preservation and simulation, and then appealing to the known decidability of reachability in plain simply-typed, handler-free finitary PCF due to Ong ’06 and Kobayashi ’09 (Endo et al., 18 Aug 2025).

The same paper also proves that any ATM-typable nonrecursive finitary PCF program with effect handlers is strongly normalizing. The argument is that if the source has no recursion, then its CPS transform also has no recursion; the target is then an ordinary simply-typed α\alpha07-calculus term with records and without recursion or effects, hence strongly normalizing; simulation transfers termination back to the source.

ATM is sometimes presented as increasing expressiveness because it permits programs that standard no-ATM systems cannot type. The finitary PCF work confirms this intuition by exhibiting programs typable with ATM but not without it. One example is

α\alpha08

The paper states that no-ATM simple typing fails because the return clause body x has type unit while the op-clause body (k x; true) has type bool, and the standard handler rule requires a single answer type for all clauses. ATM succeeds by assigning

α\alpha09

This is a direct instance of ATM enabling distinct answer types in return and op clauses (Endo et al., 18 Aug 2025).

The same paper also shows the converse: there are programs typable without ATM that become untypable with ATM. Its example is

α\alpha10

where

α\alpha11

Under the simple system one can give α\alpha12 and α\alpha13, with both clauses producing unit. Under ATM, however, the subtyping constraints force the answer-type transformation α\alpha14 to become pure, which conflicts with the effectful return clause invoking op (). The paper states that a contradiction follows, so α\alpha15 is untypable in ATM.

This bidirectional separation matters for interpretation. ATM is not simply “more permissive” than traditional handler typing. The data explicitly states that there are programs typable with ATM but not without it, and also programs typable without ATM that become untypable with ATM. A plausible implication is that ATM imposes a finer structural discipline on continuations: it enlarges expressiveness along some dimensions while ruling out programs whose control flow cannot be assigned coherent answer-type transformations.

Related notions clarify this landscape. ARM is the case where only refinements change while the underlying base type remains the same (Kawamata et al., 2023). AEM is the temporal-effect analogue, where what changes is the answer effect of the continuation rather than an ordinary answer type (Sekiyama et al., 2022). Across these variants, the unifying pattern is a require–guarantee view of delimited control: a captured continuation assumes one answer specification before resumption and establishes another afterward.

Topic to Video (Beta)

No one has generated a video about this topic yet.

Whiteboard

No one has generated a whiteboard explanation for this topic yet.

Follow Topic

Get notified by email when new papers are published related to Answer Type Modification (ATM).