skip to main content
10.1145/3240719.3241788acmconferencesArticle/Chapter ViewAbstractPublication PagesicfpConference Proceedingsconference-collections
research-article

Typing, representing, and abstracting control: functional pearl

Published: 27 September 2018 Publication History

Abstract

A well known technique to implement programming languages with delimited control operators shift and reset is to translate programs into continuation passing style (CPS). We can iterate the CPS translation to obtain the CPS hierarchy and to implement a family of control operators shifti and reseti. This functional pearl retells the story of a family of delimited control operators and their translation to lambda calculus via the CPS hierarchy. Prior work on the CPS hierarchy fixes a level of n control operators for the entire program upfront, but we allow different parts of the program to live at different levels. It turns out that taking shift0 rather than shift as the basis for the family of control operators is essential for this. Our source language is a typed embedding in the dependently typed language Idris. Our target language is a HOAS embedding in Idris. The translation avoids administrative beta- and eta-redexes at all levels of the CPS hierarchy, by iterating well-known techniques for the non-iterated CPS translation.

References

[1]
Malgorzata Biernacka, Dariusz Biernacki, and Sergueï Lenglet. 2011. Typing Control Operators in the CPS Hierarchy. In Proceedings of the Conference on Principles and Practice of Declarative Programming. ACM, New York, NY, USA, 12.
[2]
Edwin Brady. 2013. Idris, a general-purpose dependently typed programming language: Design and implementation. Journal of Functional Programming 23, 5 (2013), 552–593.
[3]
Olivier Danvy and Andrzej Filinski. 1990. Abstracting Control. In Proceedings of the 1990 ACM Conference on LISP and Functional Programming (LFP ’90). ACM, New York, NY, USA.
[4]
Oliver Danvy and Andrzex Filinski. 1992. Representing control: A study of the CPS transformation. Mathematical Structures in Computer Science 2, 4 (1992), 361–391.
[5]
R Kent Dyvbig, Simon Peyton Jones, and Amr Sabry. 2007. A monadic framework for delimited continuations. Journal of Functional Programming 17, 6 (2007), 687–730.
[6]
Yukiyoshi Kameyama. 2004. Axioms for delimited continuations in the CPS hierarchy. In International Workshop on Computer Science Logic. Springer, 442–457.
[7]
Oleg Kiselyov and Chung-chieh Shan. 2007. A Substructural Type System for Delimited Continuations. In Typed Lambda Calculi and Applications, Simona Ronchi Della Rocca (Ed.). Springer Berlin Heidelberg, Berlin, Heidelberg, 223–239.
[8]
Marek Materzok and Dariusz Biernacki. 2011. Subtyping Delimited Continuations. In Proceedings of the 16th ACM SIGPLAN International Conference on Functional Programming (ICFP ’11). ACM, New York, NY, USA, 81–93.
[9]
Marek Materzok and Dariusz Biernacki. 2012. A dynamic interpretation of the CPS hierarchy. In Proceedings of the Asian Symposium on Programming Languages and Systems. Springer, 296–311.
[10]
Frank Pfenning and Conal Elliot. 1988. Higher-Order Abstract Syntax. In Proceedings of the Conference on Programming Language Design and Implementation. ACM, 199–208.
[11]
Peter J. Thiemann. 1996. Cogen in six Lines. In Proceedings of the International Conference on Functional Programming. ACM, 180–189.

Cited By

View all
  • (2023)From Capabilities to Regions: Enabling Efficient Compilation of Lexical Effect HandlersProceedings of the ACM on Programming Languages10.1145/36228317:OOPSLA2(941-970)Online publication date: 16-Oct-2023
  • (2022)A typed continuation-passing translation for lexical effect handlersProceedings of the 43rd ACM SIGPLAN International Conference on Programming Language Design and Implementation10.1145/3519939.3523710(566-579)Online publication date: 9-Jun-2022
  • (2022)Region-based Resource Management and Lexical Exception Handlers in Continuation-Passing StyleProgramming Languages and Systems10.1007/978-3-030-99336-8_18(492-519)Online publication date: 5-Apr-2022
  • Show More Cited By

Recommendations

Comments

Information & Contributors

Information

Published In

cover image ACM Conferences
TyDe 2018: Proceedings of the 3rd ACM SIGPLAN International Workshop on Type-Driven Development
September 2018
90 pages
ISBN:9781450358255
DOI:10.1145/3240719
Permission to make digital or hard copies of all or part of this work for personal or classroom use is granted without fee provided that copies are not made or distributed for profit or commercial advantage and that copies bear this notice and the full citation on the first page. Copyrights for components of this work owned by others than the author(s) must be honored. Abstracting with credit is permitted. To copy otherwise, or republish, to post on servers or to redistribute to lists, requires prior specific permission and/or a fee. Request permissions from [email protected].

Sponsors

Publisher

Association for Computing Machinery

New York, NY, United States

Publication History

Published: 27 September 2018

Permissions

Request permissions for this article.

Check for updates

Author Tags

  1. CPS Hierarchy
  2. Compilation
  3. Continua- tion Passing Style
  4. Control Effects
  5. Delimited Control

Qualifiers

  • Research-article

Conference

ICFP '18
Sponsor:

Upcoming Conference

ICFP '25
ACM SIGPLAN International Conference on Functional Programming
October 12 - 18, 2025
Singapore , Singapore

Contributors

Other Metrics

Bibliometrics & Citations

Bibliometrics

Article Metrics

  • Downloads (Last 12 months)17
  • Downloads (Last 6 weeks)2
Reflects downloads up to 05 Mar 2025

Other Metrics

Citations

Cited By

View all
  • (2023)From Capabilities to Regions: Enabling Efficient Compilation of Lexical Effect HandlersProceedings of the ACM on Programming Languages10.1145/36228317:OOPSLA2(941-970)Online publication date: 16-Oct-2023
  • (2022)A typed continuation-passing translation for lexical effect handlersProceedings of the 43rd ACM SIGPLAN International Conference on Programming Language Design and Implementation10.1145/3519939.3523710(566-579)Online publication date: 9-Jun-2022
  • (2022)Region-based Resource Management and Lexical Exception Handlers in Continuation-Passing StyleProgramming Languages and Systems10.1007/978-3-030-99336-8_18(492-519)Online publication date: 5-Apr-2022
  • (2022)What You See Is What You Get: Practical Effect Handlers in Capability-Passing StyleErnst Denert Award for Software Engineering 202010.1007/978-3-030-83128-8_3(15-43)Online publication date: 1-Jan-2022
  • (2020)Effects as capabilities: effect handlers and lightweight effect polymorphismProceedings of the ACM on Programming Languages10.1145/34281944:OOPSLA(1-30)Online publication date: 13-Nov-2020
  • (2020)Compiling effect handlers in capability-passing styleProceedings of the ACM on Programming Languages10.1145/34089754:ICFP(1-28)Online publication date: 3-Aug-2020

View Options

Login options

View options

PDF

View or Download as a PDF file.

PDF

eReader

View online with eReader.

eReader

Figures

Tables

Media

Share

Share

Share this Publication link

Share on social media