Contextual Modal Types for Algebraic Effects and Handlers
Open Access
- 1 August 2021
- journal article
- Published by Association for Computing Machinery (ACM) in Proceedings of the ACM on Programming Languages
Abstract
Programming languages with algebraic effects often track the computations' effects using type-and-effect systems. In this paper, we propose to view an algebraic effect theory of a computation as a variable context; consequently, we propose to track algebraic effects of a computation with contextual modal types. We develop ECMTT, a novel calculus which tracks algebraic effects by a contextualized variant of the modal. (necessity) operator, that it inherits from Contextual Modal Type Theory (CMTT). Whereas type-and-effect systems add effect annotations on top of a prior programming language, the effect annotations in ECMTT are inherent to the language, as they are managed by programming constructs corresponding to the logical introduction and elimination forms for the. modality. Thus, the type-and-effect system of ECMTT is actually just a type system. Our design obtains the properties of local soundness and completeness, and determines the operational semantics solely by beta-reduction, as customary in other logic-based calculi. In this view, effect handlers arise naturally as a witness that one context (i.e., algebraic theory) can be reached from another, generalizing explicit substitutions from CMTT. To the best of our knowledge, ECMTT is the first system to relate algebraic effects to modal types. We also see it as a step towards providing a correspondence in the style of Curry and Howard that may transfer a number of results from the fields of modal logic and modal type theory to that of algebraic effects.Keywords
All Related Versions
Funding Information
- Ministerio de Ciencia, Innovación y Universidades (PGC2018-102210- B-I00)
- European Research Council (ERC2016-COG-724464)
This publication has 50 references indexed in Scilit:
- Explicit effect subtypingJournal of Functional Programming, 2020
- Local algebraic effect theoriesJournal of Functional Programming, 2020
- Doo bee doo bee dooJournal of Functional Programming, 2020
- Effect handlers via generalised continuationsJournal of Functional Programming, 2020
- Shallow Effect Handlers2018
- An Introduction to Algebraic Effects and Handlers. Invited tutorial paperElectronic Notes in Theoretical Computer Science, 2015
- Programming with algebraic effects and handlersJournal of Logical and Algebraic Methods in Programming, 2015
- Continuation-passing style models complete for intuitionistic logicAnnals of Pure and Applied Logic, 2013
- Denotation of contextual modal type theory (CMTT): Syntax and meta-programmingJournal of Applied Logic, 2013
- Nominal logic, a first order theory of names and bindingInformation and Computation, 2003