Answer-Type Modification without Tears: Prompt-Passing Style Translation for Typed Delimited-Control Operators

Ikuo Kobori
Yukiyoshi Kameyama
Oleg Kiselyov

The salient feature of delimited-control operators is their ability to modify answer types during computation. The feature, answer-type modification (ATM for short), allows one to express various interesting programs such as typed printf compactly and nicely, while it makes it difficult to embed these operators in standard functional languages.

In this paper, we present a typed translation of delimited-control operators shift and reset with ATM into a familiar language with multi-prompt shift and reset without ATM, which lets us use ATM in standard languages without modifying the type system. Our translation generalizes Kiselyov's direct-style implementation of typed printf, which uses two prompts to emulate the modification of answer types, and passes them during computation. We prove that our translation preserves typing. As the naive prompt-passing style translation generates and passes many prompts even for pure terms, we show an optimized translation that generate prompts only when needed, which is also type-preserving. Finally, we give an implementation in the tagless-final style which respects typing by construction.

In Olivier Danvy and Ugo de'Liguoro: Proceedings of the Workshop on Continuations (WoC 2015), London, UK, April 12th 2015, Electronic Proceedings in Theoretical Computer Science 212, pp. 36–52.
Published: 19th June 2016.

ArXived at: http://dx.doi.org/10.4204/EPTCS.212.3 bibtex PDF
References in reconstructed bibtex, XML and HTML format (approximated).
Comments and questions to: eptcs@eptcs.org
For website issues: webmaster@eptcs.org