Constrained type families

We present an approach to support partiality in type-level computation without compromising expressiveness or type safety. Existing frameworks for type-level computation either require totality or implicitly assume it. For example, type families in Haskell provide a powerful, modular means of defining type-level computation. However, their current design implicitly assumes that type families are total, introducing nonsensical types and significantly complicating the metatheory of type families and their extensions. We propose an alternative design, using qualified types to pair type-level computations with predicates that capture their domains. Our approach naturally captures the intuitive partiality of type families, simplifying their metatheory. As evidence, we present the first complete proof of consistency for a language with closed type families.

[1]  Mark P. Jones Simplifying and improving qualified types , 1995, FPCA '95.

[2]  Martin Odersky,et al.  Type classes as objects and implicits , 2010, OOPSLA.

[3]  Simon L. Peyton Jones,et al.  System F with type equality coercions , 2007, TLDI '07.

[4]  Simon L. Peyton Jones,et al.  Giving Haskell a promotion , 2012, TLDI '12.

[5]  Stephanie Weirich,et al.  Visible Type Application , 2016, ESOP.

[6]  Mark P. Jones,et al.  Type Classes with Functional Dependencies , 2000, ESOP.

[7]  J. Garrett Morris Variations on variants , 2015, Haskell.

[8]  Simon L. Peyton Jones,et al.  Closed type families with overlapping equations , 2014, POPL.

[9]  Simon L. Peyton Jones,et al.  Associated type synonyms , 2005, ICFP '05.

[10]  Edwin Brady Practical Erasure in Dependently Typed Languages , 2015 .

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

[12]  Manuel M. T. Chakravarty,et al.  Modular type classes , 2007, POPL '07.

[13]  Neil D. Jones,et al.  The size-change principle for program termination , 2001, POPL '01.

[14]  Simon L. Peyton Jones,et al.  Type Classes in Haskell , 1994, ESOP.

[15]  J. Girard,et al.  Proofs and types , 1989 .

[16]  Ralf Lämmel,et al.  Strongly typed heterogeneous collections , 2004, Haskell '04.

[17]  Mark P. Jones,et al.  Instance chains: type class programming without overlapping instances , 2010, ICFP '10.

[18]  Sam Lindley,et al.  Embedding session types in Haskell , 2016, Haskell.

[19]  Simon Peyton Jones,et al.  Type classes: an exploration of the design space , 1997 .

[20]  Simon L. Peyton Jones,et al.  Injective type families for Haskell , 2015, Haskell.

[21]  Wouter Swierstra,et al.  Data types à la carte , 2008, Journal of Functional Programming.

[22]  Bruno Barras,et al.  The Implicit Calculus of Constructions as a Programming Language with Dependent Types , 2008, FoSSaCS.

[23]  Simon L. Peyton Jones,et al.  Type checking with open type functions , 2008, ICFP.

[24]  Neil D. Jones,et al.  Termination Analysis of Higher-Order Functional Programs , 2005, APLAS.

[25]  Patrick Bahr Composing and decomposing data types: a closed type families implementation of data types à la carte , 2014, WGP '14.

[26]  D. Scott Identity and existence in intuitionistic logic , 1979 .

[27]  Simon Peyton Jones,et al.  Safe zero-cost coercions for Haskell , 2016, J. Funct. Program..

[28]  Mark P. Jones Qualified Types: Theory and Practice , 1994 .

[29]  Philip Wadler,et al.  How to make ad-hoc polymorphism less ad hoc , 1989, POPL '89.

[30]  Richard A. Eisenberg,et al.  Dependent Types in Haskell: Theory and Practice , 2016, ArXiv.

[31]  Riccardo Pucella,et al.  Haskell session types with (almost) no class , 2008, Haskell '08.

[32]  Richard A. Eisenberg,et al.  Experience report , 2014, Haskell.

[33]  John C. Reynolds,et al.  Towards a theory of type structure , 1974, Symposium on Programming.