Repository logo
 

Combining Effects and Coeffects via Grading

Accepted version
Peer-reviewed

Loading...
Thumbnail Image

Change log

Abstract

$\textit{Effects}$ and $\textit{coeffects}$ are two general, complementary aspects of program behaviour. They roughly correspond to computations which change the execution context (effects) versus computations which make demands on the context (coeffects). Effectful features include partiality, non-determinism, input-output, state, and exceptions. Coeffectful features include resource demands, variable access, notions of linearity, and data input requirements.

The effectful or coeffectful behaviour of a program can be captured and described via type-based analyses, with fine grained information provided by monoidal effect annotations and semiring coeffects. Various recent work has proposed models for such typed calculi in terms of $\textit{graded (strong) monads}$ for effects and $\textit{graded (monoidal) comonads}$ for coeffects.

Effects and coeffects have been studied separately so far, but in practice many computations are both effectful and coeffectful, e.g., possibly throwing exceptions but with resource requirements. To remedy this, we introduce a new general calculus with a combined $\textit{effect-coeffect system}$. This can describe both the $\textit{changes}$ and $\textit{requirements}$ that a program has on its context, as well as interactions between these effectful and coeffectful features of computation. The effect-coeffect system has a denotational model in terms of effect-graded monads and coeffect-graded comonads where interaction is expressed via the novel concept of $\textit{graded distributive laws}$. This graded semantics unifies the syntactic type theory with the denotational model. We show that our calculus can be instantiated to describe in a natural way various different kinds of interaction between a program and its evaluation context.

Description

This is the author accepted manuscript. It is currently under an indefinite embargo pending publication by the Association for Computing Machinery.

Journal Title

International Conference on Functional Programming

Conference Name

Journal ISSN

1523-2867

Volume Title

Publisher

Association for Computing Machinery

Rights and licensing

Except where otherwised noted, this item's license is described as All Rights Reserved
Sponsorship
Engineering and Physical Sciences Research Council (EP/M026124/1)
Orchard was supported by EPSRC grant EP/M026124/1 and EP/K011715/1 (whilst previously at Imperial College London), Katsumata by JSPS KAKENHI grant JP15K00014, Uustalu by Estonian Min. of Educ. and Res. grant IUT33-13 and Estonian Sci. Found. grant 9475. Gaboardi’s work was done in part while at the University of Dundee, UK supported by EPSRC grant EP/M022358/1.

Relationships

Is supplemented by: