Idris 2: Quantitative Type Theory in Practice

Dependent types allow us to express precisely what a function is intended to do. Recent work on Quantitative Type Theory (QTT) extends dependent type systems with linearity, also allowing precision in expressing when a function can run. This is promising, because it suggests the ability to design and reason about resource usage protocols, such as we might find in distributed and concurrent programming, where the state of a communication channel changes throughout program execution. As yet, however, there has not been a full-scale programming language with which to experiment with these ideas. Idris 2 is a new version of the dependently typed language Idris, with a new core language based on QTT, supporting linear and dependent types. In this paper, we introduce Idris 2, and describe how QTT has influenced its design. We give examples of the benefits of QTT in practice including: expressing which data is erased at run time, at the type level; and, resource tracking in the type system leading to type-safe concurrent programming with session types. 2012 ACM Subject Classification Software and its engineering → Functional languages

[1]  Edwin Brady,et al.  Practical implementation of a dependently typed functional programming language , 2005 .

[2]  Rui Shi,et al.  A linear type system for multicore programming in ATS , 2013, Sci. Comput. Program..

[3]  Nathan Mishra-Linger,et al.  Erasure and Polymorphism in Pure Type Systems , 2008, FoSSaCS.

[4]  Andreas Haeberlen,et al.  Linear dependent types for differential privacy , 2013, POPL.

[5]  Wim Vanderbauwhede,et al.  Value-Dependent Session Design in a Dependently Typed Language , 2019, PLACES@ETAPS.

[6]  Conor McBride,et al.  Inductive Families Need Not Store Their Indices , 2003, TYPES.

[7]  Stephanie Weirich,et al.  A specification for dependent types in Haskell , 2017, Proc. ACM Program. Lang..

[8]  James Cheney,et al.  A List of Successes That Can Change the World , 2016 .

[9]  Richard Sharp,et al.  Linear Types for Packet Processing , 2004, ESOP.

[10]  Derek Dreyer,et al.  RustBelt: securing the foundations of the rust programming language , 2017, Proc. ACM Program. Lang..

[11]  Nick Benton,et al.  Integrating Dependent and Linear Types , 2016 .

[12]  Conor McBride,et al.  Type-and-scope safe programs and their proofs , 2017, CPP.

[13]  Jonathan Aldrich,et al.  Typestate-oriented programming , 2009, OOPSLA Companion.

[14]  Nobuko Yoshida,et al.  Multiparty asynchronous session types , 2008, POPL '08.

[15]  Marinus J. Plasmeijer,et al.  Uniqueness Typing Simplified , 2008, IFL.

[16]  Éric Tanter,et al.  Foundations of Typestate-Oriented Programming , 2014, ACM Trans. Program. Lang. Syst..

[17]  Kohei Honda,et al.  Types for Dyadic Interaction , 1993, CONCUR.

[18]  Robert Atkey,et al.  Parameterised notions of computation , 2006, J. Funct. Program..

[19]  J. G. Morrisett,et al.  Ynot: dependent types for imperative programs , 2008, ICFP.

[20]  Dale Miller,et al.  Unification Under a Mixed Prefix , 1992, J. Symb. Comput..

[21]  Ken Friis Larsen,et al.  Session types for Rust , 2015, WGP@ICFP.

[22]  Nils Anders Danielsson Total parser combinators , 2010, ICFP '10.

[23]  U. Norell,et al.  Towards a practical programming language based on dependent type theory , 2007 .

[24]  Sam Lindley,et al.  Exceptional asynchronous session types: session types without tiers , 2019, Proc. ACM Program. Lang..

[25]  Dominic A. Orchard,et al.  Quantitative program reasoning with graded modal types , 2019, Proc. ACM Program. Lang..

[26]  Dominic A. Orchard,et al.  Graded Modal Dependent Type Theory , 2020, ESOP.

[27]  Simon L. Peyton Jones,et al.  Linear Haskell: practical linearity in a higher-order polymorphic language , 2017, Proc. ACM Program. Lang..

[28]  Magnus Carlsson,et al.  An exercise in dependent types: A well-typed interpreter , 1999 .

[29]  J. Garrett Morris The best of both worlds: linear functional programming without compromise , 2016, ICFP.

[30]  A. H. Robinson,et al.  Results of a prototype television bandwidth compression scheme , 1967 .

[31]  Conor McBride How to keep your neighbours in order , 2014, ICFP.

[32]  Philip Wadler,et al.  Linear Types can Change the World! , 1990, Programming Concepts and Methods.

[33]  Edwin Brady Type-driven Development of Concurrent Communicating Systems , 2017, Comput. Sci..

[34]  Riccardo Pucella,et al.  Practical affine types , 2011, POPL '11.

[35]  Edwin Brady Resource-Dependent Algebraic Effects , 2014, Trends in Functional Programming.

[36]  Edwin Brady,et al.  Idris, a general-purpose dependently typed programming language: Design and implementation , 2013, Journal of Functional Programming.

[37]  Adam Michael Gundry,et al.  Type inference, Haskell and dependent types , 2013 .

[38]  Armando Solar-Lezama,et al.  Program synthesis from polymorphic refinement types , 2015, PLDI.

[39]  A dependently typed calculus with pattern matching and erasure inference , 2020, Proc. ACM Program. Lang..

[40]  Peter Thiemann,et al.  Label-dependent session types , 2019, Proc. ACM Program. Lang..

[41]  Robert Atkey,et al.  Syntax and Semantics of Quantitative Type Theory , 2018, LICS.

[42]  Pritam Choudhury,et al.  A graded dependent type system with a usage-aware semantics , 2020, Proc. ACM Program. Lang..

[43]  Stephanie Weirich,et al.  A role for dependent types in Haskell , 2019, Proc. ACM Program. Lang..

[44]  Simon Peyton Jones,et al.  Tackling the Awkward Squad: monadic input/output, concurrency, exceptions, and foreign-language calls in Haskell , 2005 .