Skip to Main content Skip to Navigation
Conference papers

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 metadata

Cited literature [20 references]  Display  Hide  Download
Contributor : Matthias Puech <>
Submitted on : Monday, December 19, 2016 - 3:04:11 PM
Last modification on : Friday, April 30, 2021 - 10:02:39 AM
Long-term archiving on: : Tuesday, March 21, 2017 - 12:01:25 PM


Files produced by the author(s)


  • HAL Id : hal-01419473, version 1


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



Record views


Files downloads