English

Latent Effects for Reusable Language Components: Extended Version

Programming Languages 2021-08-26 v1

Abstract

The development of programming languages can be quite complicated and costly. Hence, much effort has been devoted to the modular definition of language features that can be reused in various combinations to define new languages and experiment with their semantics. A notable outcome of these efforts is the algebra-based "datatypes a la carte" (DTC) approach. When combined with algebraic effects, DTC can model a wide range of common language features. Unfortunately, the current state of the art does not cover modular definitions of advanced control-flow mechanisms that defer execution to an appropriate point, such as call-by-name and call-by-need evaluation, as well as (multi-)staging. This paper defines latent effects, a generic class of such control-flow mechanisms. We demonstrate how function abstractions, lazy computations and a MetaML-like staging can all be expressed in a modular fashion using latent effects, and how they can be combined in various ways to obtain complex semantics. We provide a full Haskell implementation of our effects and handlers with a range of examples.

Keywords

Cite

@article{arxiv.2108.11155,
  title  = {Latent Effects for Reusable Language Components: Extended Version},
  author = {Birthe van den Berg and Tom Schrijvers and Casper Bach-Poulsen and Nicolas Wu},
  journal= {arXiv preprint arXiv:2108.11155},
  year   = {2021}
}

Comments

extended version of APLAS 2021 paper

R2 v1 2026-06-24T05:24:20.182Z