skip to main content
10.1145/3337932.3338813acmconferencesArticle/Chapter ViewAbstractPublication PagespldiConference Proceedingsconference-collections
short-paper

Towards improved GADT reasoning in Scala

Published: 17 July 2019 Publication History

Abstract

Generalized algebraic data types (GADT) have been notoriously difficult to implement correctly in Scala. Both major Scala compilers, Scalac and Dotty, are currently known to have type soundness holes related to them. In particular, covariant GADTs have exposed paradoxes due to Scala's inheritance model. We informally explore foundations for GADTs within Scala's core type system, to guide a principled understanding and implementation of GADTs in Scala.

References

[1]
Nada Amin, Karl Samuel Grütter, Martin Odersky, TiarkRompf, and Sandro Stucki. 2016. The Essence of Dependent Object Types. In WadlerFest 2016, Sam Lindley, Conor McBride, Phil Trinder, and Don Sannella (Eds.). Springer, Edinburgh, UK.
[2]
Nada Amin and Ross Tate. 2016. Java and Scala's Type Systems Are Unsound: The Existential Crisis of Null Pointers. In Proceedings of the 2016 ACM SIGPLAN International Conference on Object-Oriented Programming, Systems, Languages, and Applications (OOPSLA 2016). ACM, New York, NY, USA, 838--848.
[3]
Corrado Böhm and Alessandro Berarducci. 1985. Automatic synthesis of typed Lambda-programs on term algebras. Theoretical Computer Science 39 (Jan. 1985), 135--154.
[4]
James Cheney and Ralf Hinze. 2003. First-class phantom types. Technical Report. Cornell University.
[5]
Burak Emir, Martin Odersky, and John Williams. 2007. Matching Objects with Patterns. In ECOOP2007 - Object-Oriented Programming (Lecture Notes in Computer Science), Erik Ernst (Ed.). Springer Berlin Heidelberg, 273--298.
[6]
Jacques Garrigue and Didier Rémy. 2013. Ambivalent types for principal type inference with GADTs. In Asian Symposium on Programming Languages and Systems. Springer, 257--272.
[7]
Paolo G. Giarrusso. 2013. Open GADTs and Declaration-site Variance: A Problem Statement. In Proceedings of the 4th Workshop on Scala (SCALA '13). ACM, New York, NY, USA, 5:1--5:4.
[8]
Samuel Gruetter. 2016. Connecting Scala to DOT. MSc semester project, EPFL (June 2016). https://github.com/samuelgruetter/dot-calculus/blob/master/doc/Connectine-Scala-to-DOT/report.pdf
[9]
Christian Hofer and Klaus Ostermann. 2010. Modular Domain-specific Language Components in Scala. In Proceedings of the Ninth International Conference on Generative Programming and Component Engineering (GPCE '10). ACM, New York, NY, USA, 83--92.
[10]
Jan Martin Jansen. 2013. Programming in the Λ-Calculus: From Church to Scott and Back. In Essays Dedicated to Rinus Plasmeijer on the Occasion of His 61st Birthday on The Beauty of Functional Code - Volume 8106. Springer-Verlag, Berlin, Heidelberg, 168--180.
[11]
Andrew Kennedy and Claudio V. Russo. 2005. Generalized Algebraic Data Types and Object-oriented Programming. In Proceedings of the 20th Annual ACM SIGPLAN Conference on Object-oriented Programming, Systems, Languages, and Applications (OOPSLA '05), ACM, NewYork, NY, USA, 21--40.
[12]
Pieter Koopman, Rinus Plasmeijer, and Jan Martin Jansen. 2014. Church Encoding of Data Types Considered Harmful for Implementations: Functional Pearl. In Proceedings of the 26Nd 2014 International Symposium on Implementation and Application of Functional Languages (WL '14). ACM, New York, NY, USA, 4:1--4:12.
[13]
Abel Nieto. 2017. Towards Algorithmic Typing for DOT (Short Paper). In Proceedings of the 8th ACM SIGPLAN International Symposium on Scala (SCALA 2017). ACM, New York, NY, USA, 2--7.
[14]
Martin Odersky, Guillaume Martres, and Dmitry Petrashko. 2016. Implementing Higher-kinded Types in Dotty. In Proceedings of the 2016 7th ACM SIGPLAN Symposium on Scala (SCALA 2016). ACM, New York, NY, USA, 51--60.
[15]
Lionel Parreaux, Amir Shaikhha, and ChristophE. Koch. 2017. Quoted Staged Rewriting: A Practical Approach to Library-defined Optimizations. In Proceedings of the 16th ACM SIGPLAN International Conference on Generative Programming: Concepts and Experiences (GPCE 2017). ACM, New York, NY, USA, 131--145.
[16]
Marianna Rapoport and Ondřej Lhoták. 2019. A Path To DOT: Formalizing Fully-Path-Dependent Types. (2019). arXiv:cs/1904.07298 http://arxiv.org/abs/1904.07298
[17]
Tiark Rompf and Nada Amin. 2015. From F to DOT: Type Soundness Proofs with Definitional Interpreters. (Oct. 2015). https://arxiv.org/abs/1510.05216v2
[18]
Tiark Rompf and Martin Odersky. 2010. Lightweight Modular Staging: A Pragmatic Approach to Runtime Code Generation and Compiled DSLs. In Proceedings of the Ninth International Conference on Generative Programming and Component Engineering (GPCE '10). ACM, New York, NY, USA, 127--136.
[19]
Gabriel Scherer and Didier Rémy. 2013. GADTs Meet Subtyping. In Programming Languages and Systems (Lecture Notes in Computer Science), Matthias Felleisen and Philippa Gardner (Eds.). Springer Berlin Heidelberg, 554--573.
[20]
Martin Sulzmann, Manuel Chakravarty, Simon Peyton Jones, and Kevin Donnelly. 2011. System F with type equality coercions. https://www.microsoft.com/en-us/research/publication/system-f-with-type-equal-coercions/
[21]
Hongwei Xi, Chiyan Chen, and Gang Chen. 2003. Guarded Recursive Datatype Constructors. In Proceedings of the 30th ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages (POPL '03). ACM, New York, NY, USA, 224--235.

Cited By

View all

Recommendations

Comments

Information & Contributors

Information

Published In

cover image ACM Conferences
Scala '19: Proceedings of the Tenth ACM SIGPLAN Symposium on Scala
July 2019
37 pages
ISBN:9781450368247
DOI:10.1145/3337932
Permission to make digital or hard copies of all or part of this work for personal or classroom use is granted without fee provided that copies are not made or distributed for profit or commercial advantage and that copies bear this notice and the full citation on the first page. Copyrights for components of this work owned by others than the author(s) must be honored. Abstracting with credit is permitted. To copy otherwise, or republish, to post on servers or to redistribute to lists, requires prior specific permission and/or a fee. Request permissions from [email protected].

Sponsors

Publisher

Association for Computing Machinery

New York, NY, United States

Publication History

Published: 17 July 2019

Permissions

Request permissions for this article.

Check for updates

Author Tags

  1. DOT
  2. Scala
  3. generalized algebraic data types

Qualifiers

  • Short-paper

Conference

Scala '19
Sponsor:
Scala '19: Tenth ACM SIGPLAN Scala Symposium
July 17, 2019
London, United Kingdom

Acceptance Rates

Scala '19 Paper Acceptance Rate 5 of 6 submissions, 83%;
Overall Acceptance Rate 5 of 6 submissions, 83%

Contributors

Other Metrics

Bibliometrics & Citations

Bibliometrics

Article Metrics

  • Downloads (Last 12 months)25
  • Downloads (Last 6 weeks)0
Reflects downloads up to 13 Jan 2025

Other Metrics

Citations

Cited By

View all

View Options

Login options

View options

PDF

View or Download as a PDF file.

PDF

eReader

View online with eReader.

eReader

Media

Figures

Other

Tables

Share

Share

Share this Publication link

Share on social media