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.
- M. M. T. Chakravarty, G. Keller, and S. Peyton Jones. Associated type synonyms. In ACM SIGPLAN International Conference on Functional Programming, 2005a. Google Scholar
Digital Library
- 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 Scholar
Digital Library
- J. Cheney and R. Hinze. First-class phantom types. Technical report, Cornell University, 2003.Google Scholar
- 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 Scholar
- R. A. Eisenberg and S. Weirich. Dependently typed programming with singletons. In ACM SIGPLAN Haskell Symposium, 2012. Google Scholar
Digital Library
- 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 Scholar
Digital Library
- K.-F. Faxén. A static semantics for Haskell. Journal of Functional Programming, 12(4--5), July 2002. Google Scholar
Digital Library
- A. Fischbach and J. Hannan. Specification and correctness of lambda lifting. Journal of Functional Programming, 13(3), May 2003. Google Scholar
Digital Library
- A. Gundry. Type Inference, Haskell and Dependent Types. PhD thesis, University of Strathclyde, 2013.Google Scholar
Digital Library
- T. Johnsson. Lambda lifting: Transforming programs to recursive equations. In Conference on Functional Programming Languages and Computer Architecture, 1985. Google Scholar
Digital Library
- M. P. Jones. Typing Haskell in Haskell. In Haskell Workshop, 1999.Google Scholar
- M. P. Jones. Type classes with functional dependencies. In European Symposium on Programming, 2000. Google Scholar
Digital Library
- A. Kennedy. Programming Languages and Dimensions. PhD thesis, University of Cambridge, 1996.Google Scholar
- S. Lindley and C. McBride. Hasochism: the pleasure and pain of dependently typed Haskell programming. In ACM SIGPLAN Haskell Symposium, 2013. Google Scholar
Digital Library
- S. Marlow. Haskell 2010 Language Report. Technical report, 2010.Google Scholar
- T. Muranushi and R. A. Eisenberg. Experience report: Type-checking polymorphic units for astrophysics research in Haskell. In ACM SIGPLAN Haskell Symposium, 2014. Google Scholar
Digital Library
- 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 Scholar
Digital Library
- 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 Scholar
Digital Library
- J. Reynolds. Definitional interpreters for higher-order programming languages. In ACM Annual Conference, 1972. Google Scholar
Digital Library
- 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 Scholar
Digital Library
- T. Sheard and S. Peyton Jones. Template metaprogramming for Haskell. ACM SIGPLAN Notices, 37(12), Dec. 2002. Google Scholar
Digital Library
- 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 Scholar
Digital Library
- 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 Scholar
Digital Library
- 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 Scholar
Digital Library
- S. Weirich, J. Hsu, and R. A. Eisenberg. System FC with explicit kind equality. In ACM SIGPLAN International Conference on Functional Programming, 2013. Google Scholar
Digital Library
- 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 Scholar
Digital Library
Index Terms
Promoting functions to type families in Haskell
Recommendations
Injective type families for Haskell
Haskell '15Haskell, as implemented by the Glasgow Haskell Compiler (GHC), allows expressive type-level programming. The most popular type-level programming extension is TypeFamilies, which allows users to write functions on types. Yet, using type functions can ...
Promoting functions to type families in Haskell
Haskell '14: Proceedings of the 2014 ACM SIGPLAN symposium on HaskellHaskell, 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 ...
Injective type families for Haskell
Haskell '15: Proceedings of the 2015 ACM SIGPLAN Symposium on HaskellHaskell, as implemented by the Glasgow Haskell Compiler (GHC), allows expressive type-level programming. The most popular type-level programming extension is TypeFamilies, which allows users to write functions on types. Yet, using type functions can ...







Comments