Recovering Purity with Comonads and Capabilities

07/16/2019
by   Vikraman Choudhury, et al.
0

In this paper, we take a pervasively effectful (in the style of ML) typed lambda calculus, and show how to extend it to permit capturing pure expressions with types. Our key observation is that, just as the pure simply-typed lambda calculus can be extended to support effects with a monadic type discipline, an impure typed lambda calculus can be extended to support purity with a comonadic type discipline. We establish the correctness of our type system via a simple denotational model, which we call the capability space model. Our model formalizes the intuition common to systems programmers that the ability to perform effects should be controlled via access to a permission or capability, and that a program is capability-safe if it performs no effects that it does not have a runtime capability for. We then identify the axiomatic categorical structure that the capability space model validates, and use these axioms to give a categorical semantics for our comonadic type system. We then give an equational theory (substitution and the call-by-value β and η laws) for the imperative lambda calculus, and show its soundness relative to this semantics. Finally, we give a translation of the pure simply-typed lambda calculus into our comonadic imperative calculus, and show that any two terms which are βη-equal in the STLC are equal in the equational theory of the comonadic calculus, establishing that pure programs can be mapped in an equation-preserving way into our imperative calculus.

READ FULL TEXT

page 1

page 2

page 3

page 4

research
06/13/2023

The Undecidability of Typability in the Lambda-Pi-Calculus

The set of pure terms which are typable in the λΠ-calculus in a given co...
research
05/25/2023

On the Simply-Typed Functional Machine Calculus: Categorical Semantics and Strong Normalisation

The Functional Machine Calculus (FMC) was recently introduced as a gener...
research
11/23/2022

The Functional Machine Calculus II: Semantics

The Functional Machine Calculus (FMC), recently introduced by the author...
research
12/16/2022

Call-By-Name Is Just Call-By-Value with Delimited Control

Delimited control operator shift0 exhibits versatile capabilities: it ca...
research
12/09/2022

Extended Addressing Machines for PCF, with Explicit Substitutions

Addressing machines have been introduced as a formalism to construct mod...
research
06/04/2018

On the Soundness of Coroutines with Snapshots

Coroutines are a general control flow construct that can eliminate contr...
research
04/24/2023

Two Decreasing Measures for Simply Typed Lambda-Terms (Extended Version)

This paper defines two decreasing measures for terms of the simply typed...

Please sign up or login with your details

Forgot password? Click here to reset