Typeful Continuations

Abstract : Continuation-passing style translations, or CPS, are used notably in compilers. They make a functional program more explicit by sequentializing its computations and reifying its control. They have been used as an intermediate language in many compilers. Yet, we cannot directly use Plotkin's original CPS translation to design compilers, for several reasons: i) the resulting terms it produces are verbose (they contain " administrative redexes " , a well-studied problem) and inefficient (they perform nested beta-reductions sequentially); and ii) their loose syntax can hide possible further optimizations, in particular tail call elimination. These issues have been solved in isolation and on paper, but never combined together and formalized, which i) is necessary to scale to safe, full-featured optimizing compilers and ii) is not a mere juxtaposition of the techniques but requires insight on the design of CPS translations themselves. We propose to design and implement in OCaml a compacting, optimizing CPS translation, while using OCaml's type system to verify that it maps well-typed terms to well-typed terms in a tightly restricted syntactical form (the " typeful " approach to formalization). The resulting artifact can be used directly to design optimizing compilers, and the path towards it offers a tutorial on optimizing CPS translations, and yet another use case for OCaml's advanced type system.
Document type :
Conference papers
Complete list of metadatas

Cited literature [20 references]  Display  Hide  Download

https://hal.archives-ouvertes.fr/hal-01419473
Contributor : Matthias Puech <>
Submitted on : Monday, December 19, 2016 - 3:04:11 PM
Last modification on : Wednesday, March 27, 2019 - 4:41:29 PM
Long-term archiving on: Tuesday, March 21, 2017 - 12:01:25 PM

File

typeful-continuations.pdf
Files produced by the author(s)

Identifiers

  • HAL Id : hal-01419473, version 1

Citation

Matthias Puech. Typeful Continuations. JFLA 2017 - 28ème Journées Francophones des Langages Applicatifs, Jan 2017, Gourette, France. pp.1-14. ⟨hal-01419473⟩

Share

Metrics

Record views

244

Files downloads

157