skip to main content
research-article
Open Access
Artifacts Available
Artifacts Evaluated & Functional

Constrained type families

Published:29 August 2017Publication History
Skip Abstract Section

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.

Skip Supplemental Material Section

Supplemental Material

References

  1. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  2. 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 ScholarGoogle ScholarCross RefCross Ref
  3. 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 ScholarGoogle ScholarCross RefCross Ref
  4. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  5. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  6. Richard A. Eisenberg. 2016. Dependent Types in Haskell: Theory and Practice. Ph.D. Dissertation. University of Pennsylvania.Google ScholarGoogle Scholar
  7. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  8. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  9. Jean-Yves Girard, Paul Taylor, and Yves Lafont. 1989. Proofs and Types. Cambridge University Press, New York, NY, USA.Google ScholarGoogle Scholar
  10. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  11. 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 ScholarGoogle Scholar
  12. Mark P. Jones. 1994. Qualified Types: Theory and Practice. Cambridge University Press. Google ScholarGoogle ScholarCross RefCross Ref
  13. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  14. 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 ScholarGoogle ScholarCross RefCross Ref
  15. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  16. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  17. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  18. 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 ScholarGoogle ScholarCross RefCross Ref
  19. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  20. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  21. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  22. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  23. 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 ScholarGoogle Scholar
  24. 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 ScholarGoogle Scholar
  25. John C. Reynolds. 1974. Towards a theory of type structure. In Paris Colloquium on Programming. Springer-Verlag, 408–423. Google ScholarGoogle ScholarCross RefCross Ref
  26. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  27. 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 ScholarGoogle ScholarCross RefCross Ref
  28. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  29. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  30. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  31. Wouter Swierstra. 2008. Data types à la carte. JFP 18, 04 (2008), 423–436. Google ScholarGoogle ScholarDigital LibraryDigital Library
  32. 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 ScholarGoogle Scholar
  33. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  34. 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 ScholarGoogle ScholarDigital LibraryDigital Library

Index Terms

  1. Constrained type families

      Recommendations

      Comments

      Login options

      Check if you have access through your login credentials or your institution to get full access on this article.

      Sign in

      Full Access

      PDF Format

      View or Download as a PDF file.

      PDF

      eReader

      View online with eReader.

      eReader
      About Cookies On This Site

      We use cookies to ensure that we give you the best experience on our website.

      Learn more

      Got it!