skip to main content
research-article

Promoting functions to type families in Haskell

Published:03 September 2014Publication History
Skip Abstract Section

Abstract

Haskell, as implemented in the Glasgow Haskell Compiler (GHC), is enriched with many extensions that support type-level programming, such as promoted datatypes, kind polymorphism, and type families. Yet, the expressiveness of the type-level language remains limited. It is missing many features present at the term level, including case expressions, anonymous functions, partially-applied functions, and let expressions. In this paper, we present an algorithm - with a proof of correctness - to encode these term-level constructs at the type level. Our approach is automated and capable of promoting a wide array of functions to type families. We also highlight and discuss those term-level features that are not promotable. In so doing, we offer a critique on GHC's existing type system, showing what it is already capable of and where it may want improvement.

We believe that delineating the mismatch between GHC's term level and its type level is a key step toward supporting dependently typed programming.

References

  1. M. M. T. Chakravarty, G. Keller, and S. Peyton Jones. Associated type synonyms. In ACM SIGPLAN International Conference on Functional Programming, 2005a. Google ScholarGoogle ScholarDigital LibraryDigital Library
  2. M. M. T. Chakravarty, G. Keller, S. Peyton Jones, and S. Marlow. Associated types with class. In ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages, 2005b. Google ScholarGoogle ScholarDigital LibraryDigital Library
  3. J. Cheney and R. Hinze. First-class phantom types. Technical report, Cornell University, 2003.Google ScholarGoogle Scholar
  4. R. A. Eisenberg and J. Stolarek. Promoting functions to type families in Haskell (extended version). Technical Report MS-CIS-14-09, University of Pennsylvania, 2014.Google ScholarGoogle Scholar
  5. R. A. Eisenberg and S. Weirich. Dependently typed programming with singletons. In ACM SIGPLAN Haskell Symposium, 2012. Google ScholarGoogle ScholarDigital LibraryDigital Library
  6. R. A. Eisenberg, D. Vytiniotis, S. Peyton Jones, and S. Weirich. Closed type families with overlapping equations. In ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages, 2014. Google ScholarGoogle ScholarDigital LibraryDigital Library
  7. K.-F. Faxén. A static semantics for Haskell. Journal of Functional Programming, 12(4--5), July 2002. Google ScholarGoogle ScholarDigital LibraryDigital Library
  8. A. Fischbach and J. Hannan. Specification and correctness of lambda lifting. Journal of Functional Programming, 13(3), May 2003. Google ScholarGoogle ScholarDigital LibraryDigital Library
  9. A. Gundry. Type Inference, Haskell and Dependent Types. PhD thesis, University of Strathclyde, 2013.Google ScholarGoogle ScholarDigital LibraryDigital Library
  10. T. Johnsson. Lambda lifting: Transforming programs to recursive equations. In Conference on Functional Programming Languages and Computer Architecture, 1985. Google ScholarGoogle ScholarDigital LibraryDigital Library
  11. M. P. Jones. Typing Haskell in Haskell. In Haskell Workshop, 1999.Google ScholarGoogle Scholar
  12. M. P. Jones. Type classes with functional dependencies. In European Symposium on Programming, 2000. Google ScholarGoogle ScholarDigital LibraryDigital Library
  13. A. Kennedy. Programming Languages and Dimensions. PhD thesis, University of Cambridge, 1996.Google ScholarGoogle Scholar
  14. S. Lindley and C. McBride. Hasochism: the pleasure and pain of dependently typed Haskell programming. In ACM SIGPLAN Haskell Symposium, 2013. Google ScholarGoogle ScholarDigital LibraryDigital Library
  15. S. Marlow. Haskell 2010 Language Report. Technical report, 2010.Google ScholarGoogle Scholar
  16. T. Muranushi and R. A. Eisenberg. Experience report: Type-checking polymorphic units for astrophysics research in Haskell. In ACM SIGPLAN Haskell Symposium, 2014. Google ScholarGoogle ScholarDigital LibraryDigital Library
  17. S. Peyton Jones, D. Vytiniotis, S. Weirich, and G. Washburn. Simple unification-based type inference for GADTs. In ACM SIGPLAN International Conference on Functional Programming, 2006. Google ScholarGoogle ScholarDigital LibraryDigital Library
  18. S. Peyton Jones, D. Vytiniotis, S. Weirich, and M. Shields. Practical type inference for arbitrary-rank types. Journal of Functional Programming, 17(1), Jan. 2007. Google ScholarGoogle ScholarDigital LibraryDigital Library
  19. J. Reynolds. Definitional interpreters for higher-order programming languages. In ACM Annual Conference, 1972. Google ScholarGoogle ScholarDigital LibraryDigital Library
  20. P. Sewell, F. Zappa Nardelli, S. Owens, G. Peskine, T. Ridge, S. Sarkar, and R. Strnisa. Ott: Effective tool support for the working semanticist. Journal of Functional Programming, 20(1), Jan. 2010. Google ScholarGoogle ScholarDigital LibraryDigital Library
  21. T. Sheard and S. Peyton Jones. Template metaprogramming for Haskell. ACM SIGPLAN Notices, 37(12), Dec. 2002. Google ScholarGoogle ScholarDigital LibraryDigital Library
  22. M. Sulzmann, M. M. T. Chakravarty, S. Peyton Jones, and K. Donnelly. System F with type equality coercions. In ACM SIGPLAN Workshop on Types in Languages Design and Implementation, 2007. Google ScholarGoogle ScholarDigital LibraryDigital Library
  23. D. Vytiniotis, S. Peyton Jones, T. Schrijvers, and M. Sulzmann. OutsideIn(modular type inference with local assumptions. Journal of Functional Programming, 21(4--5), Sept. 2011. Google ScholarGoogle ScholarDigital LibraryDigital Library
  24. P. Wadler and S. Blott. How to make ad-hoc polymorphism less ad hoc. In ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages, 1989. Google ScholarGoogle ScholarDigital LibraryDigital Library
  25. S. Weirich, J. Hsu, and R. A. Eisenberg. System FC with explicit kind equality. In ACM SIGPLAN International Conference on Functional Programming, 2013. Google ScholarGoogle ScholarDigital LibraryDigital Library
  26. B. Yorgey, S. Weirich, J. Cretin, S. Peyton Jones, D. Vytiniotis, and J. P. Magalhães. Giving Haskell a promotion. In ACM SIGPLAN Workshop on Types in Language Design and Implementation, 2012. Google ScholarGoogle ScholarDigital LibraryDigital Library

Index Terms

  1. Promoting functions to type families 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

        • Published in

          cover image ACM SIGPLAN Notices
          ACM SIGPLAN Notices  Volume 49, Issue 12
          Haskell '14
          December 2014
          141 pages
          ISSN:0362-1340
          EISSN:1558-1160
          DOI:10.1145/2775050
          • Editor:
          • Andy Gill
          Issue’s Table of Contents
          • cover image ACM Conferences
            Haskell '14: Proceedings of the 2014 ACM SIGPLAN symposium on Haskell
            September 2014
            154 pages
            ISBN:9781450330411
            DOI:10.1145/2633357

          Copyright © 2014 ACM

          Publisher

          Association for Computing Machinery

          New York, NY, United States

          Publication History

          • Published: 3 September 2014

          Check for updates

          Qualifiers

          • research-article

        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!