Reference. Finally tagless, partially evaluated: Tagless staged interpreters for simpler typed languages

We have built the first family of tagless interpretations for a higher-order typed object language in a typed metalanguage (Haskell or ML) that require no dependent types, generalized algebraic data types, or postprocessing to eliminate tags. The statically type-preserving interpretations include an evaluator, a compiler (or staged evaluator), a partial evaluator, and call-by-name and call-by-value continuation-passing style (CPS) transformers. Our principal technique is to encode de Bruijn or higher-order abstract syntax using combinator functions rather than data constructors. In other words, we represent object terms not in an initial algebra but using the coalgebraic structure of the λ-calculus. Our representation also simulates inductive maps from types to types, which are required for typed partial evaluation and CPS transformations. Our encoding of an object term abstracts uniformly over the family of ways to interpret it, yet statically assures that the interpreters never get stuck. This family of interpreters thus demonstrates again that it is useful to abstract over higher-kinded types.

Cite

Cite as @carette-2009-finally (helia, typst) · \cite{carette-2009-finally} (LaTeX)
BibTeX
bibtex · 1 line
@article{carette-2009-finally, title={Finally tagless, partially evaluated: Tagless staged interpreters for simpler typed languages}, volume={19}, ISSN={1469-7653}, url={http://dx.doi.org/10.1017/s0956796809007205}, DOI={10.1017/s0956796809007205}, number={5}, journal={Journal of Functional Programming}, publisher={Cambridge University Press (CUP)}, author={CARETTE, JACQUES and KISELYOV, OLEG and SHAN, CHUNG-CHIEH}, year={2009}, month=Apr, pages={509–543} }
hayagriva YAML (typst)
yaml · 19 lines
carette-2009-finally:
  type: article
  title: 'Finally tagless, partially evaluated: Tagless staged interpreters for simpler typed languages'
  author:
  - CARETTE, JACQUES
  - KISELYOV, OLEG
  - SHAN, CHUNG-CHIEH
  date: 2009-04
  page-range: 509-543
  url: http://dx.doi.org/10.1017/s0956796809007205
  serial-number:
    doi: 10.1017/s0956796809007205
    issn: 1469-7653
  parent:
    type: periodical
    title: Journal of Functional Programming
    publisher: Cambridge University Press (CUP)
    issue: 5
    volume: 19
Cited by (7)

Programmable Property-Based Testing keles-2026-programmable

Property-based testing (PBT) is a popular technique for establishing confidence in software, where users write properties —i.e. executable specifications—that can be checked many times in a loop by a testing framework. In modern PBT frameworks, properties are usually written in shallowly embedded domain-specific languages, and their definition is tightly coupled to the way they are tested. Such frameworks often provide convenient configuration options to customize aspects of the testing process, but users are limited to precisely what library authors had the prescience to allow for when developing the framework; if they want more flexibility, they may need to write a new framework from scratch. We propose a new, deeper language for properties based on a mixed embedding that we call deferred binding abstract syntax , which reifies properties as a data structure and decouples them from the property runners that execute them. We implement this language in Rocq and Racket, leveraging the power of dependent and dynamic types, respectively. Finally, we showcase the flexibility of this new approach by implementing a variety of property runners in a shared framework, highlighting domain-specific testing improvements that can be unlocked by more programmable testing.
PDF · DOI · arXiv · pldb

Symbolic Execution of Hadamard-Toffoli Quantum Circuits carette-2023-symbolic

DOI

Leveraging the Information Contained in Theory Presentations carette-2020-leveraging

A theorem prover without an extensive library is much less useful to its potential users. Algebra, the study of algebraic structures, is a core component of such libraries. Algebraic theories also are themselves structured, the study of which was started as Universal Algebra. Various constructions (homomorphism, term algebras, products, etc) and their properties are both universal and constructive. Thus they are ripe for being automated. Unfortunately, current practice still requires library builders to write these by hand. We first highlight specific redundancies in libraries of existing systems. Then we describe a framework for generating these derived concepts from theory definitions. We demonstrate the usefulness of this framework on a test library of 227 theories.
DOI · arXiv

Partially-static data as free extension of algebras yallop-2018-partially

Partially-static data structures are a well-known technique for improving binding times. However, they are often defined in an ad-hoc manner, without a unifying framework to ensure full use of the equations associated with each operation. We present a foundational view of partially-static data structures as free extensions of algebras for suitable equational theories, i.e. the coproduct of an algebra and a free algebra in the category of algebras and their homomorphisms. By precalculating these free extensions, we construct a high-level library of partially-static data representations for common algebraic structures. We demonstrate our library with common use-cases from the literature: string and list manipulation, linear algebra, and numerical simplification.
PDF · DOI · pldb

Type-and-scope safe programs and their proofs allais-2017-type

PDF · DOI · pldb

Functors are type refinement systems mellies_zeilberger_2015

The standard reading of type theory through the lens of category theory is based on the idea of viewing a type system as a category of well-typed terms. We propose a basic revision of this reading: rather than interpreting type systems as categories, we describe them as functors from a category of typing derivations to a category of underlying terms. Then, turning this around, we explain how in fact any functor gives rise to a generalized type system, with an abstract notion of typing judgment, typing derivations and typing rules. This leads to a purely categorical reformulation of various natural classes of type systems as natural classes of functors.

The main purpose of this paper is to describe the general framework (which can also be seen as providing a categorical analysis of refinement types), and to present a few applications. As a larger case study, we revisit Reynolds’ paper on “The Meaning of Types” (2000), showing how the paper’s main results may be reconstructed along these lines.

PDF · DOI · pldb

Folding domain-specific languages: deep and shallow embeddings (functional Pearl) gibbons-2014-folding

PDF · DOI · pldb
Cites 81 works (1 here)
With notes (1)

Higher-order abstract syntax pfenning-1988-higher

PDF · DOI · pldb
External (80)
carette-2009-finally reference entries/refs/carette-2009-finally/carette-2009-finally.hel