# GADTs meet subtyping

@inproceedings{Scherer2013GADTsMS, title={GADTs meet subtyping}, author={Gabriel Scherer and Didier R{\'e}my}, booktitle={ESOP}, year={2013} }

While generalized algebraic datatypes (GADTs) are now considered well-understood, adding them to a language with a notion of subtyping comes with a few surprises. [...] Key Method We allow variance annotations in GADT definitions, study their soundness, and present a sound and complete algorithm to check them. Our work may be applied to real-world ML-like languages with explicit subtyping such as OCaml, or to languages with general subtyping constraints. Expand

#### Supplemental Presentations

#### 9 Citations

Towards improved GADT reasoning in Scala

- Computer Science
- SCALA@ECOOP
- 2019

This work informally explore foundations for GADTs within Scala's core type system, to guide a principled understanding and implementation of GadTs in Scala. Expand

Formal foundations for GADTs in Scala

- 2020

GADTs are a very useful language feature that allow encoding some invariants in types. GADT reasoning is currently implemented in Scala and Dotty, but it’s plagued with soundness issues. To get a… Expand

Unboxing Mutually Recursive Type Definitions in OCaml

- Computer Science
- ArXiv
- 2018

The notion of separability as a semantic for the unboxing criterion is explained, and a set of inference rules to check separability is proposed, from which a new implementation of the unboxes check that properly supports mutually-recursive definitions is derived. Expand

Safe zero-cost coercions for Haskell

- Computer Science
- ICFP 2014
- 2014

A new mechanism is presented that allows for zero-cost conversions between generative type abstractions and their representations, even when such types are deeply nested and type safety in the presence of these conversions is proved. Expand

Safe zero-cost coercions for Haskell

- Computer Science
- Journal of Functional Programming
- 2016

This work presents a new mechanism that allows for zero-cost conversions between generative type abstractions and their representations, even when such types are deeply nested, and proves type safety in the presence of these conversions. Expand

First-Class Subtypes

- Computer Science, Biology
- ML/OCaml
- 2017

This work presents several encodings of first-class subtypes using existing features of the OCaml language, and shows that any such encodations are interconvertible, and illustrates the utility of the encodments with several examples. Expand

Terms of use : Click here Safe zero-cost coercions for Haskell

- 2016

Generative type abstractions – present in Haskell, OCaml, and other languages – are useful concepts to help prevent programmer errors. They serve to create new types that are distinct at compile time… Expand

Safe Zero-cost Coercions for Haskell (extended version)

- Computer Science
- 2014

A new mechanism is presented that allows for zero-cost conversions between generative type abstractions and a run-time representation of that type. Expand

Implementing path-dependent GADT reasoning for Scala 3

- Computer Science
- SCALA@SPLASH
- 2021

This paper shows how the existing constraint-based GADT reasoning of the Scala 3 compiler is extended to also consider path-dependent types, making Scala’s support for G ADT programming more complete and bringing Scala closer to its formal foundations. Expand

#### References

SHOWING 1-10 OF 30 REFERENCES

Polarized Subtyping for Sized Types

- Mathematics, Computer Science
- CSR
- 2006

An algorithm for deciding polarized higher-order subtyping without bounded quantification is presented and a direct proof of completeness is given, without constructing a model or establishing a strong normalization theorem. Expand

Variance and Generalized Constraints for C# Generics

- Mathematics, Computer Science
- ECOOP
- 2006

A system of type-safe variance for C that supports the declaration of covariant and contravariant type parameters on generic types and formalizes the subtype relation in both declarative and syntax-directed style. Expand

A constraint-based approach to guarded algebraic data types

- Computer Science
- TOPL
- 2007

It is proved that HMG(X) is sound and that, provided recursive definitions carry a type annotation, type inference can be reduced to constraint solving. Expand

Relaxing the Value Restriction

- Computer Science
- APLAS
- 2002

This work uses a subtyping based approach to recover part of this lost polymorphism, without changing the type algebra itself, and this has significant applications. Expand

Generalized algebraic data types and object-oriented programming

- Computer Science
- OOPSLA '05
- 2005

This work proposes a generalization of the type constraint mechanisms of C# and Java to both avoid the need for casts in GADT programs and higher-order contortions in PADTs programs, and presents a Visitor pattern for GADTs, and describes a refined switch construct as an alternative to virtual dispatch on datatypes. Expand

Intensionality, extensionality, and proof irrelevance in modal type theory

- Mathematics, Computer Science
- Proceedings 16th Annual IEEE Symposium on Logic in Computer Science
- 2001

A uniform type theory that integrates intensionality, extensionality and proof irrelevance as judgmental concepts is developed that contrasts with previous approaches that, a priori, distinguished propositions from specifications. Expand

Mathematical Structures in Computer Science

- Computer Science
- 2012

Computability, despite having exact access to its own discrete data type, provides a unique tool for the investigation of ‘unpredictability’ in both Physics and Biology through its fine-grained analysis of undecidability. Expand

Gallium – INRIA) GADTs meet Subtyping

- Gallium – INRIA) GADTs meet Subtyping
- 2014

GADTs meet subtyping. Long version, available electronically. URL: http://gallium.inria.fr/ ~ remy/gadts

- GADTs meet subtyping. Long version, available electronically. URL: http://gallium.inria.fr/ ~ remy/gadts
- 2013

Gallium) GADTs meet Subtyping

- Gallium) GADTs meet Subtyping
- 2013