scispace - formally typeset
Open AccessJournal ArticleDOI

A Functional Correspondence between Monadic Evaluators and Abstract Machines for Languages with Computational Effects

TLDR
This work shows how to derive new abstract machines from monadic evaluators for the computational lambda-calculus by inline the components of the monad in the evaluator and derives the corresponding abstract machine by closure-converting, CPS-transforming, and defunctionalizing this inlined interpreter.
Abstract
We extend our correspondence between evaluators and abstract machines from the pure setting of the lambda-calculus to the impure setting of the computational lambda-calculus. Specifically, we show how to derive new abstract machines from monadic evaluators for the computational lambda-calculus. Starting from a monadic evaluator and a given monad, we inline the components of the monad in the evaluator and we derive the corresponding abstract machine by closure-converting, CPS-transforming, and defunctionalizing this inlined interpreter. We illustrate the construction first with the identity monad, obtaining yet again the CEK machine, and then with a state monad, an exception monad, and a combination of both. In addition, we characterize the tail-recursive stack inspection presented by Clements and Felleisen at ESOP 2003 as a canonical state monad. Combining this state monad with an exception monad, we construct an abstract machine for a language with exceptions and properly tail-recursive stack inspection. The construction scales to other monads--including one more properly dedicated to stack inspection than the state monad--and other monadic evaluators.

read more

Content maybe subject to copyright    Report

Citations
More filters
Journal ArticleDOI

Combining effects: sum and tensor

TL;DR: This work reformulates Moggi's monadic paradigm for modelling computational effects using the notion of enriched Lawvere theory, together with its relationship with strong monads; this emphasises the importance of the operations that produce the effects.
Journal ArticleDOI

A functional correspondence between monadic evaluators and abstract machines for languages with computational effects

TL;DR: The correspondence between evaluators and abstract machines is extended to the impure setting of the λ-calculus, and the tail-recursive stack inspection presented by Clements and Felleisen is characterized as a lifted state monad, which enables to combine this stack-inspection monad with other monads and to construct abstract machines for languages with properly tail- Recursion stack inspection and other computational effects.
Journal ArticleDOI

A functional correspondence between call-by-need evaluators and lazy abstract machines

TL;DR: This article derives a lazy abstract machine from an ordinary call-by-need evaluator that threads a heap of updatable cells, using closure conversion, transformation into continuation-passing style, and defunctionalization of continuations.
Journal ArticleDOI

An Operational Foundation for Delimited Continuations in the CPS Hierarchy

TL;DR: In this article, an abstract machine and a reduction semantics for the lambda-calculus extended with control operators that give access to delimited continuations in the CPS hierarchy are presented.

On Evaluation Contexts, Continuations, and the Rest of the Computation

Olivier Danvy
TL;DR: A constructive corollary of Reynolds’s historical warning about depending on the evaluation order of a metalanguage for an interpreter is presented: the two best-known abstract machines for the λ-calculus are in fact the call-by-name and call- by-value counterparts of the same (evaluation-order dependent) interpreter for the â’calculus.