Data-Codata Symmetry and its Interaction with Evaluation Order

11/23/2022
by   David Binder, et al.
0

Data types and codata types are, as the names suggest, often seen as duals of each other. However, most programming languages do not support both of them in their full generality, or if they do, they are still seen as distinct constructs with separately defined type-checking, compilation, etc. Rendel et al. were the first to propose variants of two standard program transformations, de- and refunctionalization, as a test to gauge and improve the symmetry between data and codata types. However, in previous works, codata and data were still seen as separately defined language constructs, with de- and refunctionalization being defined as similar but separate algorithms. These works also glossed over interactions between the aforementioned transformations and evaluation order, which leads to a loss of desirable η expansion equalities. We argue that the failure of complete symmetry is due to the inherent asymmetry of natural deduction as the logical foundation of the language design. Natural deduction is asymmetric in that its focus is on producers (proofs) of types, whereas consumers (contexts, continuations, refutations) have a second-class status. Inspired by existing sequent-calculus-based language designs, we present the first language design that is fully symmetric in that the issues of polarity (data type vs codata types) and evaluation order (call-by-value vs call-by-name) are untangled and become independent attributes of a single form of type declaration. Both attributes, polarity and evaluation order, can be changed independently by one algorithm each. In particular, defunctionalization and refunctionalization are now one algorithm. Evaluation order can be defined and changed individually for each type, independently from polarity. By allowing only certain combinations of evaluation order and polarity, the aforementioned η laws can be restored.

READ FULL TEXT

page 1

page 2

page 3

page 4

research
08/21/2023

Typing Composable Coroutines

Coroutine, as a powerful programming construct, is widely used in asynch...
research
11/28/2022

Mechanized Noninterference for Gradual Security

This paper presents the first machine-checked proof of noninterference f...
research
05/31/2019

On the Interaction of Object-Oriented Design Patterns and Programming Languages

Design patterns are distilled from many real systems to catalog common p...
research
09/26/2022

A metalanguage for cost-aware denotational semantics

We present two metalanguages for developing synthetic cost-aware denotat...
research
10/21/2020

Contextual Linear Types for Differential Privacy

Language support for differentially-private programming is both crucial ...
research
06/19/2017

Generic Approach to Certified Static Checking of Module-like Constructs

In this paper we consider the problem of certified static checking of mo...
research
10/01/2019

Augmenting learning using symmetry in a biologically-inspired domain

Invariances to translation, rotation and other spatial transformations a...

Please sign up or login with your details

Forgot password? Click here to reset