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

Higher-order type-level programming in Haskell

Published:26 July 2019Publication History
Skip Abstract Section

Abstract

Type family applications in Haskell must be fully saturated. This means that all type-level functions have to be first-order, leading to code that is both messy and longwinded. In this paper we detail an extension to GHC that removes this restriction. We augment Haskell’s existing type arrow, |->|, with an unmatchable arrow, | >|, that supports partial application of type families without compromising soundness. A soundness proof is provided. We show how the techniques described can lead to substantial code-size reduction (circa 80%) in the type-level logic of commonly-used type-level libraries whilst simultaneously improving code quality and readability.

Skip Supplemental Material Section

Supplemental Material

a102-kiss.webm

References

  1. Thorsten Altenkirch, Conor McBride, and Peter Morris. 2006. Generic programming with dependent types. In International Spring School on Datatype-Generic Programming. Springer, 209–257.Google ScholarGoogle Scholar
  2. Maximilian C. Bolingbroke. 2011. Constraint Kinds for GHC. http://blog.omega- prime.co.uk/2011/09/10/constraint- kindsfor- ghc/Google ScholarGoogle Scholar
  3. Edwin Brady. 2013. Idris, a general-purpose dependently typed programming language: Design and implementation. J. Funct. Prog. 23 (2013).Google ScholarGoogle Scholar
  4. Manuel M. T. Chakravarty, Gabriele Keller, and Simon Peyton Jones. 2005. Associated Type Synonyms. In International Conference on Functional Programming (ICFP ’05). ACM. Google ScholarGoogle ScholarDigital LibraryDigital Library
  5. Richard A Eisenberg. 2016. Dependent types in Haskell: Theory and Practice. Ph.D. Dissertation. University of Pennsylvania.Google ScholarGoogle Scholar
  6. Richard A Eisenberg and Simon Peyton Jones. 2017. Levity polymorphism. In ACM SIGPLAN Notices, Vol. 52. ACM, 525–539. Google ScholarGoogle ScholarDigital LibraryDigital Library
  7. Richard A. Eisenberg and Jan Stolarek. 2014. Promoting Functions to Type Families in Haskell. In ACM SIGPLAN Haskell Symposium. Google ScholarGoogle ScholarDigital LibraryDigital Library
  8. 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, New York, NY, USA, 671–683. Google ScholarGoogle ScholarDigital LibraryDigital Library
  9. Richard A. Eisenberg, Stephanie Weirich, and Hamidhasan G. Ahmed. 2016. Visible Type Application. In ESOP. Google ScholarGoogle ScholarDigital LibraryDigital Library
  10. GHC. 2019. GHC User Manual on Type Families. https://downloads.haskell.org/~ghc/latest/docs/html/users_guide/ glasgow_exts.html#type- families Accessed: 2019-05-31.Google ScholarGoogle Scholar
  11. Adam Gundry. 2013. Type Inference, Haskell and Dependent Types. Ph.D. Dissertation. University of Strathclyde.Google ScholarGoogle Scholar
  12. Gerard P Huet. 1973. The undecidability of unification in third order logic. Information and Control 22, 3 (1973), 257–267.Google ScholarGoogle ScholarCross RefCross Ref
  13. Chung-Kil Hur. 2010. Agda with the excluded middle is inconsistent? https://coq- club.inria.narkive.com/iDuSeltD/agdawith- the- excluded- middle- is- inconsistent . Accessed: 2019-03-01.Google ScholarGoogle Scholar
  14. Oleg Kiselyov, Ralf Lämmel, and Keean Schupke. 2004. Strongly typed heterogeneous collections. In Proc. 2004 ACM SIGPLAN Workshop on Haskell (Haskell ’04). ACM, 96–107. Google ScholarGoogle ScholarDigital LibraryDigital Library
  15. Csongor Kiss, Matthew Pickering, and Nicolas Wu. 2018. Generic Deriving of Generic Traversals. In International Conference on Functional Programming (ICFP ’18). ACM. arXiv: arXiv:1805.06798Google ScholarGoogle Scholar
  16. Ralf Lämmel and Simon Peyton Jones. 2003. Scrap Your Boilerplate: A Practical Design Pattern for Generic Programming. In Types in Languages Design and Implementation. ACM Press, New York, NY, USA, 26–37. Google ScholarGoogle ScholarDigital LibraryDigital Library
  17. José Pedro Magalhães, Atze Dijkstra, Johan Jeuring, and Andres Löh. 2010. A Generic Deriving Mechanism for Haskell. In Proceedings of the Third ACM Haskell Symposium on Haskell (Haskell ’10). ACM, New York, NY, USA, 37–48. Google ScholarGoogle ScholarDigital LibraryDigital Library
  18. Dale Miller. 1992. Unification under a mixed prefix. Journal of symbolic computation 14, 4 (1992), 321–358. Google ScholarGoogle ScholarDigital LibraryDigital Library
  19. My Nguyen. 2018. Type-level visible type application. Talk, Haskell Implementors Workshop, St. Louis, MO, United States.Google ScholarGoogle Scholar
  20. Ulf Norell. 2007. Towards a practical programming language based on dependent type theory. Ph.D. Dissertation. Department of Computer Science and Engineering, Chalmers University of Technology, SE-412 96 Göteborg, Sweden.Google ScholarGoogle Scholar
  21. John Reynolds. 1972. Definitional Interpreters for Higher-Order Programming Languages. In ACM Annual Conference. Google ScholarGoogle ScholarDigital LibraryDigital Library
  22. Tim Sheard and Simon Peyton Jones. 2002. Template meta-programming for Haskell. In Proc. 2002 ACM SIGPLAN workshop on Haskell (Haskell ’02). ACM, 1–16. Google ScholarGoogle ScholarDigital LibraryDigital Library
  23. Vincent Simonet and François Pottier. 2007. A Constraint-based Approach to Guarded Algebraic Data Types. ACM Trans. Program. Lang. Syst. 29, 1, Article 1 (Jan. 2007). Google ScholarGoogle ScholarDigital LibraryDigital Library
  24. Jan Stolarek, Simon Peyton Jones, and Richard A. Eisenberg. 2015. Injective Type Families for Haskell. In Proceedings of the 2015 ACM SIGPLAN Symposium on Haskell (Haskell ’15). ACM, New York, NY, USA, 118–128. Google ScholarGoogle ScholarDigital LibraryDigital Library
  25. Martin Sulzmann, Manuel M. T. Chakravarty, Simon Peyton Jones, and Kevin Donnelly. 2007. System F with type equality coercions. In Types in languages design and implementation (TLDI ’07). ACM. Google ScholarGoogle ScholarDigital LibraryDigital Library
  26. Anish Tondwalkar. 2018. Popularity of Haskell Extensions. https://gist.github.com/atondwal/ ee869b951b5cf9b6653f7deda0b7dbd8 . Accessed: 2019-02-24.Google ScholarGoogle Scholar
  27. Dimitrios Vytiniotis, Simon Peyton Jones, Tom Schrijvers, and Martin Sulzmann. 2011. OutsideIn(X): Modular Type Inference with Local Assumptions. Journal of Functional Programming 21, 4-5 (Sept. 2011). Google ScholarGoogle ScholarDigital LibraryDigital Library
  28. Stephanie Weirich, Justin Hsu, and Richard A. Eisenberg. 2013. System FC with Explicit Kind Equality. In International Conference on Functional Programming (ICFP ’13). ACM. Google ScholarGoogle ScholarDigital LibraryDigital Library
  29. Stephanie Weirich, Antoine Voizard, Pedro Henrique Azevedo de Amorim, and Richard A. Eisenberg. 2017. A Specification for Dependent Types in Haskell. Proc. ACM Program. Lang. 1, ICFP, Article 31 (Aug. 2017), 29 pages. Google ScholarGoogle ScholarDigital LibraryDigital Library
  30. Stephanie Weirich, Dimitrios Vytiniotis, Simon Peyton Jones, and Steve Zdancewic. 2011. Generative type abstraction and type-level computation. In POPL. ACM. Google ScholarGoogle ScholarDigital LibraryDigital Library
  31. Hongwei Xi, Chiyan Chen, and Gang Chen. 2003. Guarded recursive datatype constructors. In Principles of Programming Languages (POPL ’03). ACM. Google ScholarGoogle ScholarDigital LibraryDigital Library
  32. Brent A. Yorgey, Stephanie Weirich, Julien Cretin, Simon Peyton Jones, Dimitrios Vytiniotis, and José Pedro Magalhães. 2012. Giving Haskell a promotion. In Types in Language Design and Implementation (TLDI ’12). ACM. Google ScholarGoogle ScholarDigital LibraryDigital Library

Index Terms

  1. Higher-order type-level programming in Haskell

          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!