Abstract
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.
Supplemental Material
Available for Download
Our artifact for submission is the paper proof of the soundness of the System CFC presented in our paper. There is no implementation to evaluate, and we believe that our proof is straightforward enough to meet the criteria for the artifact evaluation process. The proof appears, in full, in this document. Although all the details necessary for the proof are herein, it may be helpful to read this alongside §6 of our submission, as that section introduces the reader to the type system described here.
- Patrick Bahr. 2014. Composing and decomposing data types: a closed type families implementation of data types à la carte. In Proceedings of the 10th ACM SIGPLAN workshop on Generic programming, WGP 2014, Gothenburg, Sweden, August 31, 2014, José Pedro Magalhães and Tiark Rompf (Eds.). ACM, 71–82. Google Scholar
Digital Library
- Bruno Barras and Bruno Bernardo. 2008. The Implicit Calculus of Constructions as a Programming Language with Dependent Types. In Foundations of Software Science and Computational Structures (FOSSACS 2008), Roberto Amadio (Ed.). Springer Berlin Heidelberg, Budapest, Hungary, 365–379. Google Scholar
Cross Ref
- Joachim Breitner, Richard A. Eisenberg, Simon Peyton Jones, and Stephanie Weirich. 2016. Safe Zero-cost Coercions for Haskell. J. Funct. Program. 26 (2016), 1–79. Google Scholar
Cross Ref
- Manuel M. T. Chakravarty, Gabriele Keller, and Simon L. Peyton Jones. 2005. Associated type synonyms. In Proceedings of the 10th ACM SIGPLAN International Conference on Functional Programming, ICFP 2005, Tallinn, Estonia, September 26-28, 2005, Olivier Danvy and Benjamin C. Pierce (Eds.). ACM, 241–253. Google Scholar
Digital Library
- Derek Dreyer, Robert Harper, Manuel M. T. Chakravarty, and Gabriele Keller. 2007. Modular type classes. In Proceedings of the 34th annual ACM SIGPLAN-SIGACT symposium on Principles of programming languages (POPL ’07). ACM, Nice, France, 63–70. Google Scholar
Digital Library
- Richard A. Eisenberg. 2016. Dependent Types in Haskell: Theory and Practice. Ph.D. Dissertation. University of Pennsylvania.Google Scholar
- Richard A. Eisenberg, Dimitrios Vytiniotis, Simon Peyton Jones, and Stephanie Weirich. 2014. Closed Type Families with Overlapping Equations. In Proceedings of the 41st ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages (POPL ’14). ACM, San Diego, California, USA, 671–683. Google Scholar
Digital Library
- Richard A. Eisenberg, Stephanie Weirich, and Hamidhasan G. Ahmed. 2016. Visible Type Application. In Programming Languages and Systems - 25th European Symposium on Programming, ESOP 2016 (Lecture Notes in Computer Science), Peter Thiemann (Ed.), Vol. 9632. Springer, 229–254. Google Scholar
Digital Library
- Jean-Yves Girard, Paul Taylor, and Yves Lafont. 1989. Proofs and Types. Cambridge University Press, New York, NY, USA.Google Scholar
- Cordelia V. Hall, Kevin Hammond, Simon L. Peyton Jones, and Philip L. Wadler. 1996. Type Classes in Haskell. ACM Trans. Program. Lang. Syst. 18, 2 (March 1996). Google Scholar
Digital Library
- Thomas Hallgren. 2000. Fun with functional dependencies, or (draft) types as values in static computations in Haskell. http://www.cse.chalmers.se/~hallgren/Papers/wm01.html . (2000).Google Scholar
- Mark P. Jones. 1994. Qualified Types: Theory and Practice. Cambridge University Press. Google Scholar
Cross Ref
- Mark P. Jones. 1995. Simplifying and improving qualified types. In Proceedings of the seventh international conference on Functional programming languages and computer architecture (FPCA ’95). ACM, La Jolla, California, USA, 160–169. Google Scholar
Digital Library
- Mark P. Jones. 2000. Type Classes with Functional Dependencies. In Proceedings of the 9th European Symposium on Programming Languages and Systems (ESOP ’00). Springer-Verlag, Berlin, Germany, 230–244. Google Scholar
Cross Ref
- Oleg Kiselyov, Ralf Lämmel, and Keean Schupke. 2004. Strongly typed heterogeneous collections. In Proceedings of the 2004 ACM SIGPLAN workshop on Haskell (Haskell ’04). ACM Press, Snowbird, Utah, USA, 96–107. Google Scholar
Digital Library
- Chin Soon Lee, Neil D. Jones, and Amir M. Ben-Amram. 2001. The size-change principle for program termination. In Conference Record of POPL 2001: The 28th ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages, London, UK, January 17-19, 2001, Chris Hankin and Dave Schmidt (Eds.). ACM, 81–92. Google Scholar
Digital Library
- Sam Lindley and J. Garrett Morris. 2016. Embedding session types in Haskell. In Proceedings of the 9th International Symposium on Haskell, Haskell 2016, Nara, Japan, September 22-23, 2016, Geoffrey Mainland (Ed.). ACM, 133–145. Google Scholar
Digital Library
- Nathan Mishra-Linger and Tim Sheard. 2008. Erasure and Polymorphism in Pure Type Systems. In Foundations of Software Science and Computational Structures (FoSSaCS). Springer. Google Scholar
Cross Ref
- J. Garrett Morris. 2015. Variations on variants. In Proceedings of the 8th ACM SIGPLAN Symposium on Haskell (Haskell ’15), Ben Lippmeier (Ed.). ACM, Vancouver, BC, 71–81.Google Scholar
Digital Library
- J. Garrett Morris and Mark P. Jones. 2010. Instance chains: Type-class programming without overlapping instances. In Proceedings of the 15th ACM SIGPLAN international conference on Functional programming (ICFP ’10). ACM, Baltimore, MD. Google Scholar
Digital Library
- Takayuki Muranushi and Richard A. Eisenberg. 2014. Experience report: Type-checking polymorphic units for astrophysics research in Haskell. In Proceedings of the 2014 ACM SIGPLAN symposium on Haskell, Gothenburg, Sweden, September 4-5, 2014, Wouter Swierstra (Ed.). ACM, 31–38. Google Scholar
Digital Library
- Bruno C. d. S. Oliveira, Adriaan Moors, and Martin Odersky. 2010. Type classes as objects and implicits. In Proceedings of the 25th Annual ACM SIGPLAN Conference on Object-Oriented Programming, Systems, Languages, and Applications, OOPSLA 2010, October 17-21, 2010, Reno/Tahoe, Nevada, USA, William R. Cook, Siobhán Clarke, and Martin C. Rinard (Eds.). ACM, 341–360. Google Scholar
Digital Library
- Simon Peyton Jones, Mark P. Jones, and Erik Meijer. 1997. Type classes: An exploration of the design space. In Proceedings of the 1997 workshop on Haskell (Haskell ’97). Amsterdam, The Netherlands.Google Scholar
- Riccardo Pucella and Jesse A. Tov. 2008. Haskell session types with (almost) no class. In Proceedings of the 1st ACM SIGPLAN Symposium on Haskell, Haskell 2008, Victoria, BC, Canada, 25 September 2008. ACM, 25–36.Google Scholar
- John C. Reynolds. 1974. Towards a theory of type structure. In Paris Colloquium on Programming. Springer-Verlag, 408–423. Google Scholar
Cross Ref
- Tom Schrijvers, Simon Peyton Jones, Manuel Chakravarty, and Martin Sulzmann. 2008. Type checking with open type functions. In Proceeding of the 13th ACM SIGPLAN international conference on Functional programming (IFCP ’08). ACM, Victoria, BC, Canada, 51–62. Google Scholar
Digital Library
- Dana Scott. 1979. Identity and existence in intuitionistic logic. In Applications of Sheaves: Proceedings of the Research Symposium on Applications of Sheaf Theory to Logic, Algebra, and Analysis, Durham, July 9–21, 1977, Michael Fourman, Christopher Mulvey, and Dana Scott (Eds.). Springer Berlin Heidelberg, Berlin, Heidelberg, 660–696. Google Scholar
Cross Ref
- Damien Sereni and Neil D. Jones. 2005. Termination Analysis of Higher-Order Functional Programs. In Programming Languages and Systems, Third Asian Symposium, APLAS 2005, Tsukuba, Japan, November 2-5, 2005, Proceedings (Lecture Notes in Computer Science), Kwangkeun Yi (Ed.), Vol. 3780. Springer, 281–297. Google Scholar
Digital Library
- Jan Stolarek, Simon L. Peyton Jones, and Richard A. Eisenberg. 2015. Injective type families for Haskell. In Proceedings of the 8th ACM SIGPLAN Symposium on Haskell, Haskell 2015, Vancouver, BC, Canada, September 3-4, 2015, Ben Lippmeier (Ed.). ACM, 118–128. Google Scholar
Digital Library
- Martin Sulzmann, Manuel M. T. Chakravarty, Simon L. Peyton Jones, and Kevin Donnelly. 2007. System F with type equality coercions. In Proceedings of TLDI’07: 2007 ACM SIGPLAN International Workshop on Types in Languages Design and Implementation, Nice, France, January 16, 2007, François Pottier and George C. Necula (Eds.). ACM, 53–66. Google Scholar
Digital Library
- Wouter Swierstra. 2008. Data types à la carte. JFP 18, 04 (2008), 423–436. Google Scholar
Digital Library
- Matúš Tejiščák and Edwin Brady. 2015. Practical Erasure in Dependently Typed Languages. (2015). http://eb.host.cs. st- andrews.ac.uk/drafts/dtp- erasure- draft.pdf Draft.Google Scholar
- Philip Wadler and Stephen Blott. 1989. How to make ad-hoc polymorphism less ad hoc. In Proceedings of the 16th ACM SIGPLAN-SIGACT symposium on Principles of programming languages (POPL ’89). ACM, Austin, Texas, USA, 60–76. Google Scholar
Digital Library
- Brent A. Yorgey, Stephanie Weirich, Julien Cretin, Simon L. Peyton Jones, Dimitrios Vytiniotis, and José Pedro Magalhães. 2012. Giving Haskell a promotion. In Proceedings of TLDI 2012: The Seventh ACM SIGPLAN Workshop on Types in Languages Design and Implementation, Philadelphia, PA, USA, Saturday, January 28, 2012, Benjamin C. Pierce (Ed.). ACM, 53–66. Google Scholar
Digital Library
Index Terms
Constrained type families
Recommendations
Type families with class, type classes with family
Haskell '15: Proceedings of the 2015 ACM SIGPLAN Symposium on HaskellType classes and type families are key ingredients in Haskell programming. Type classes were introduced to deal with ad-hoc polymorphism, although with the introduction of functional dependencies, their use expanded to type-level programming. Type ...
Type families with class, type classes with family
Haskell '15Type classes and type families are key ingredients in Haskell programming. Type classes were introduced to deal with ad-hoc polymorphism, although with the introduction of functional dependencies, their use expanded to type-level programming. Type ...
Closed type families with overlapping equations
POPL '14Open, type-level functions are a recent innovation in Haskell that move Haskell towards the expressiveness of dependent types, while retaining the look and feel of a practical programming language. This paper shows how to increase expressiveness still ...






Comments