Compiling With Classical Connectives

07/30/2019
by   Paul Downen, et al.
0

The study of polarity in computation has revealed that an "ideal" programming language combines both call-by-value and call-by-name evaluation; the two calling conventions are each ideal for half the types in a programming language. But this binary choice leaves out call-by-need which is used in practice to implement lazy-by-default languages like Haskell. We show how the notion of polarity can be extended beyond the value/name dichotomy to include call-by-need by adding a mechanism for sharing which is enough to compile a Haskell-like functional language with user-defined types. The key to capturing sharing in this mixed-evaluation setting is to generalize the usual notion of polarity "shifts:" rather than just two shifts (between positive and negative) we have a family of four dual shifts. We expand on this idea of logical duality—"and" is dual to "or;" proof is dual to refutation—for the purpose of compiling a variety of types. Based on a general notion of data and codata, we show how classical connectives can be used to encode a wide range of built-in and user-defined types. In contrast with an intuitionistic logic corresponding to pure functional programming, these classical connectives bring more of the pleasant symmetries of classical logic to the computationally-relevant, constructive setting. In particular, an involutive pair of negations bridges the gulf between the wide-spread notions of parametric polymorphism and abstract data types in programming languages. To complete the study of duality in compilation, we also consider the dual to call-by-need evaluation, which shares the computation within the control flow of a program instead of computation within the information flow.

READ FULL TEXT

page 1

page 2

page 3

page 4

research
10/11/2020

A Categorical Programming Language

A theory of data types based on category theory is presented. We organiz...
research
01/20/2019

A tensorized logic programming language for large-scale data

We introduce a new logic programming language T-PRISM based on tensor em...
research
01/26/2021

Categorical semantics of a simple differential programming language

With the increased interest in machine learning, and deep learning in pa...
research
10/14/2020

PrivaLog: a privacy-aware logic programming language

Logic Programming (LP) is a subcategory of declarative programming that ...
research
02/18/2019

A Dependently Typed Library for Static Information-Flow Control in Idris

Safely integrating third-party code in applications while protecting the...
research
08/27/2018

A Systematic Approach to Programming

We show how to systematically implement a mental representation of an al...
research
05/07/2021

GADTs, Functoriality, Parametricity: Pick Two

GADTs can be represented either as their Church encodings à la Atkey, or...

Please sign up or login with your details

Forgot password? Click here to reset