Contextual Modal Types for Algebraic Effects and Handlers

03/04/2021
by   Nikita Zyuzin, et al.
0

Programming languages with algebraic effects often rely on effect annotations to track algebraic operations in a computation. This is particularly important in the presence of effect handlers, where handling of an effect may remove it from the annotation in the computation's type. In this paper we view the algebraic effect theory of a computation as a variable context, and track the effects directly in computation's modal type with ECMTT, a novel calculus for algebraic effects and handlers. Our calculus supports computations with effects and derives from Contextual Modal Type Theory (CMTT), from which it inherits a number of important logical properties. In contrast to type-and-effect systems, where effects are attached as annotations to a prior computational language, ECMMT tracks effects by a contextualized variant of the modal (necessity) operator of the intuitionistic modal logic of CMTT. In programming, the effect annotations are explicitly managed by the dedicated term constructors corresponding to the logical introduction and elimination forms for the modality. The modal foundation leads to customary logical properties of local soundness and completeness, and determines the operational semantics of ECMTT directly by β-reduction. In addition, effect handlers become a generalization of explicit substitutions, which in CMTT serve to reach one context from another. 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.

READ FULL TEXT
research
01/28/2018

Polymorphic Context for Contextual Modality

Through the Curry-Howard isomorphism between logics and calculi, necessi...
research
10/14/2022

When programs have to watch paint dry

We explore type systems and programming abstractions for the safe use of...
research
07/09/2020

Logic of computational semi-effects and categorical gluing for equivariant functors

In this paper, we revisit Moggi's celebrated calculus of computational e...
research
04/19/2023

A Calculus for Scoped Effects Handlers

Algebraic effects handlers have become a standard approach for side-...
research
05/27/2020

Local Algebraic Effect Theories

Algebraic effects are computational effects that can be described with a...
research
11/15/2021

Moebius: Metaprogramming using Contextual Types – The stage where System F can pattern match on itself (Long Version)

We describe the foundation of the metaprogramming language, Moebius, whi...
research
04/04/2023

Gradual Typing for Effect Handlers

We present a gradually typed language, GrEff, with effects and handlers ...

Please sign up or login with your details

Forgot password? Click here to reset