DeepAI AI Chat
Log In Sign Up

A case for DOT: Theoretical Foundations for Objects With Pattern Matching and GADT-style Reasoning

Many programming languages in the OO tradition now support pattern matching in some form. Historical examples include Scala and Ceylon, with the more recent additions of Java, Kotlin, TypeScript, and Flow. But pattern matching on generic class hierarchies currently results in puzzling type errors in most of these languages. Yet this combination of features occurs naturally in many scenarios, such as when manipulating typed ASTs. To support it properly, compilers need to implement a form of subtyping reconstruction: the ability to reconstruct subtyping information uncovered at runtime during pattern matching. We introduce cDOT, a new calculus in the family of Dependent Object Types (DOT) intended to serve as a formal foundation for subtyping reconstruction. Being descended from pDOT, itself a formal foundation for Scala, cDOT can be used to encode advanced object-oriented features such as generic inheritance, type constructor variance, F-bounded polymorphism, and first-class recursive modules. We demonstrate that subtyping reconstruction subsumes GADTs by encoding λ_2,Gμ, a classical constraint-based GADT calculus, into cDOT.

READ FULL TEXT

page 1

page 2

page 3

page 4

09/21/2023

The Undecidability of Third Order Pattern Matching in Calculi with Dependent Types or Type Constructors

We prove the undecidability of the third order pattern matching problem ...
08/21/2023

Typing Composable Coroutines

Coroutine, as a powerful programming construct, is widely used in asynch...
04/15/2022

Formalizing φ-calculus: a purely object-oriented calculus of decorated objects

Many calculi exist for modelling various features of object-oriented lan...
06/13/2020

Pure Pattern Calculus à la de Bruijn

It is well-known in the field of programming languages that dealing with...
03/29/2021

A simpler encoding of indexed types

In functional programming languages, generalized algebraic data types (G...
05/16/2017

A Co-contextual Type Checker for Featherweight Java (incl. Proofs)

This paper addresses compositional and incremental type checking for obj...