Abstract
We propose a core semantics for Dependent Haskell, an extension of Haskell with full-spectrum dependent types. Our semantics consists of two related languages. The first is a Curry-style dependently-typed language with nontermination, irrelevant arguments, and equality abstraction. The second, inspired by the Glasgow Haskell Compiler's core language FC, is its explicitly-typed analogue, suitable for implementation in GHC. All of our results---chiefly, type safety, along with theorems that relate these two languages---have been formalized using the Coq proof assistant. Because our work is backwards compatible with Haskell, our type safety proof holds in the presence of nonterminating computation. However, unlike other full-spectrum dependently-typed languages, such as Coq, Agda or Idris, because of this nontermination, Haskell's term language does not correspond to a consistent logic.
Supplemental Material
Available for Download
Technical appendix - complete specification of type system.
- Carlo Angiuli, Robert Harper, and Todd Wilson. 2017. Computational higher-dimensional type theory. In Proceedings of the 44th ACM SIGPLAN Symposium on Principles of Programming Languages. ACM, 680–693. Google Scholar
Digital Library
- David Aspinall and Martin Hoffman. 2005. Dependent Types. MIT Press, 45–86. http://www.cis.upenn.edu/~bcpierce/attapl/Google Scholar
- Lennart Augustsson. 1998. Cayenne—a language with dependent types. In Proc. ACM SIGPLAN International Conference on Functional Programming (ICFP ’98). ACM, 239–250. Google Scholar
Digital Library
- Brian Aydemir and Stephanie Weirich. 2010. LNgen: Tool Support for Locally Nameless Representations. Technical Report MS-CIS-10-24. Computer and Information Science, University of Pennsylvania.Google Scholar
- Henk Barendregt. 1991. Introduction to generalized type systems. J. Funct. Program. 1, 2 (1991), 125–154.Google Scholar
Cross Ref
- 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
- Marc Bezem, Thierry Coquand, and Simon Huber. 2014. A model of type theory in cubical sets. In 19th International Conference on Types for Proofs and Programs (TYPES 2013), Vol. 26. 107–128.Google Scholar
- A. Bove and V. Capretta. 2005. Modelling General Recursion in Type Theory. Mathematical Structures in Computer Science 15 (February 2005), 671–708. Cambridge University Press. Google Scholar
Digital Library
- Edwin Brady. 2005. Practical Implementation of a Dependently Typed Functional Programming Language. Ph.D. Dissertation. Durham University.Google Scholar
- Edwin Brady. 2013. Idris, a general-purpose dependently typed programming language: Design and implementation. J. Funct. Prog. 23 (2013).Google Scholar
- Joachim Breitner, Richard A. Eisenberg, Simon Peyton Jones, and Stephanie Weirich. 2014. Safe Zero-cost Coercions for Haskell. In International Conference on Functional Programming (ICFP ’14). ACM. Google Scholar
Digital Library
- Luca Cardelli. 1986. A Polymorphic Lambda Calculus with Type:Type. Technical Report 10. Degital Equipment Corporation, SRC.Google Scholar
- Chris Casinghino, Vilhelm Sjöberg, and Stephanie Weirich. 2014. Combining Proofs and Programs in a Dependently Typed Language. In POPL 2014: 41st ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages. San Diego, CA, USA, 33–45. Google Scholar
Digital Library
- Manuel M. T. Chakravarty, Gabriele Keller, and Simon Peyton Jones. 2005. Associated Type Synonyms. In International Conference on Functional Programming (ICFP ’05). ACM. Google Scholar
Digital Library
- James Cheney and Ralf Hinze. 2003. First-Class Phantom Types. Technical Report. Cornell University.Google Scholar
- Coq development team. 2004. The Coq proof assistant reference manual. LogiCal Project. http://coq.inria.fr Version 8.0.Google Scholar
- Thierry Coquand. 1986. A Calculus of Constructions. (Nov. 1986). manuscript.Google Scholar
- Julien Cretin. 2014. Erasable coercions: a unified approach to type systems. Ph.D. Dissertation. Université Paris Diderot (Paris 7).Google Scholar
- Julien Cretin and Didier Rémy. 2014. System F with Coercion Constraints. In Logics In Computer Science (LICS). ACM. Google Scholar
Digital Library
- Haskell B. Curry, J. Roger Hindley, and J.P. Seldin (Eds.). 1972. Combinatory logic: Volume II. Amsterdam: North-Holland Pub. Co.Google Scholar
- Luis Damas and Robin Milner. 1982. Principal Type-Schemes for Functional Programs. In Conference Record of the 9th Annual ACM Symposium on Principles of Programming Languages. ACM Press, New York, 207–12. Google Scholar
Digital Library
- Peter Dybjer and Anton Setzer. 1999. A finite axiomatization of inductive-recursive definitions. In Typed Lambda Calculi and Applications, volume 1581 of Lecture Notes in Computer Science. Springer, 129–146. Google Scholar
Cross Ref
- Richard A. Eisenberg. 2016. Dependent Types in Haskell: Theory and Practice. Ph.D. Dissertation. University of Pennsylvania.Google Scholar
- Richard A. Eisenberg and Simon Peyton Jones. 2017. Levity Polymorphism. In PLDI ’17. To appear. Google Scholar
Digital Library
- Richard A. Eisenberg, Stephanie Weirich, and Hamidhasan G. Ahmed. 2016. Visible Type Application. In European Symposium on Programming (ESOP). 229–254. Google Scholar
Digital Library
- H. Geuvers and F. Wiedijk. 2004. A logical framework with explicit conversions. In LFM’04, Proceedings of the Fourth International Workshop on Logical Frameworks and Meta-Languages, Cork, Ireland, Carsten Schuermann (Ed.). 32–45.Google Scholar
- Jean-Yves Girard. 1971. Une Extension De L’Interpretation De Gödel à L’Analyse, Et Son Application à L’Élimination Des Coupures Dans L’Analyse Et La Theorie Des Types. In Proceedings of the Second Scandinavian Logic Symposium, J.E. Fenstad (Ed.). Studies in Logic and the Foundations of Mathematics, Vol. 63. Elsevier, 63 – 92. http://www.sciencedirect. com/science/article/pii/S0049237X08708437Google Scholar
Cross Ref
- Jean-Yves Girard. 1972. Interprétation fonctionnelle et élimination des coupures de l’arithmétique d’ordre supérieur. Ph.D. Dissertation. Université Paris 7.Google Scholar
- Georges Gonthier, Assia Mahboubi, and Enrico Tassi. 2016. A Small Scale Reflection Extension for the Coq system. Research Report RR-6455. Inria Saclay Ile de France. https://hal.inria.fr/inria- 00258384Google Scholar
- Adam Gundry. 2013. Type Inference, Haskell and Dependent Types. Ph.D. Dissertation. University of Strathclyde.Google Scholar
- Chung-Kil Hur. 2010. Agda with the excluded middle is inconsistent? URL https://lists.chalmers.se/pipermail/agda/2010/ 001522.html .. (2010).Google Scholar
- Barry Jay and Simon Peyton Jones. 2008. Scrap Your Type Applications. In Proceedings of the 9th International Conference on Mathematics of Program Construction (MPC ’08). Springer-Verlag, Berlin, Heidelberg, 2–27. Google Scholar
Digital Library
- Garrin Kimmel, Aaron Stump, Harley D. Eades, Peng Fu, Tim Sheard, Stephanie Weirich, Chris Casinghino, Vilhelm Sjöberg, Nathin Collins, and Ki Yunh Anh. 2013. Equational reasoning about programs with general recursion and call-by-value semantics. Progress in Informatics 10 (March 2013), 19–48. http://www.nii.ac.jp/pi/ Google Scholar
Cross Ref
- Per Martin-Löf. 1971. A Theory of Types. (1971). Unpublished manuscript.Google Scholar
- Per Martin-Löf. 1975. An intuitionistic theory of types: predicative part. In Logic Colloquium ’73, Proceedings of the Logic Colloquium, H.E. Rose and J.C. Shepherdson (Eds.). Studies in Logic and the Foundations of Mathematics, Vol. 80. North-Holland, 73–118. Google Scholar
Cross Ref
- Per Martin-Löf. 1984. Intuitionistic type theory. Studies in Proof Theory, Vol. 1. Bibliopolis. iv+91 pages.Google Scholar
- Conor McBride. 2000. Elimination with a Motive. In Types for Proofs and Programs, International Workshop, TYPES 2000, Durham, UK, December 8-12, 2000, Selected Papers. 197–216. Google Scholar
Cross Ref
- Conor McBride. 2004. Epigram. (2004). http://www.dur.ac.uk/CARG/epigram .Google Scholar
- Alexandre Miquel. 2001. The Implicit Calculus of Constructions Extending Pure Type Systems with an Intersection Type Binder and Subtyping. Springer Berlin Heidelberg, Berlin, Heidelberg, 344–359. Google Scholar
Cross Ref
- Alexandre Miquel. 2010. Re: Agda with the excluded middle is inconsistent? URL https://lists.chalmers.se/pipermail/agda/ 2010/001543.html . (2010).Google Scholar
- 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 Scholar
- Simon L. Peyton Jones, Dimitrios Vytiniotis, Stephanie Weirich, and Mark Shields. 2007. Practical type inference for arbitrary-rank types. Journal of Functional Programming 17, 1 (Jan. 2007), 1–82. Google Scholar
Digital Library
- Simon L. Peyton Jones, Dimitrios Vytiniotis, Stephanie Weirich, and Geoffrey Washburn. 2006. Simple unification-based type inference for GADTs. In International Conference on Functional Programming (ICFP). Portland, OR, USA, 50–61. Google Scholar
Digital Library
- Frank Pfenning. 1992. On the Undecidability of Partial Polymorphic Type Reconstruction. Technical Report. Pittsburgh, PA, USA.Google Scholar
- F. Pfenning. 2001. Intensionality, extensionality, and proof irrelevance in modal type theory. In Proceedings 16th Annual IEEE Symposium on Logic in Computer Science. 221–230. Google Scholar
Cross Ref
- Benjamin C. Pierce and David N. Turner. 2000. Local Type Inference. ACM Trans. Program. Lang. Syst. 22, 1 (Jan. 2000), 1–44. Google Scholar
Digital Library
- John C. Reynolds. 1974. Towards a theory of type structure. In Programming Symposium, B. Robinet (Ed.). Lecture Notes in Computer Science, Vol. 19. Springer Berlin Heidelberg, 408–425. Google Scholar
Cross Ref
- Tom Schrijvers, Simon Peyton Jones, Manuel Chakravarty, and Martin Sulzmann. 2008. Type checking with open type functions. In ICFP ’08: Proceeding of the 13th ACM SIGPLAN international conference on Functional programming. ACM, New York, NY, USA, 51–62. Google Scholar
Digital Library
- Peter Sewell, Francesco Zappa Nardelli, Scott Owens, Gilles Peskine, Thomas Ridge, Susmit Sarkar, and Rok Strniša. 2010. Ott: Effective tool support for the working semanticist. Journal of Functional Programming 20, 1 (Jan. 2010). Google Scholar
Digital Library
- Vilhelm Sjöberg and Stephanie Weirich. 2015. Programming up to Congruence. In POPL 2015: 42nd ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages. Mumbai, India, 369–382. Google Scholar
Digital Library
- Matthieu Sozeau. 2008. Un environnement pour la programmation avec types dépendants. Ph.D. Dissertation. Université Paris 11, Orsay, France.Google Scholar
- Jan Stolarek, Simon Peyon Jones, and Richard A. Eisenberg. 2015. Injective Type Families for Haskell. In Haskell Symposium (Haskell ’15). ACM. Google Scholar
Digital Library
- Aaron Stump. 2016. The Calculus of Dependent Lambda Eliminations. (Sept. 2016). http://homepage.cs.uiowa.edu/~astump/ papers/cedille- draft.pdf Submitted for publication.Google Scholar
- 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 Scholar
Digital Library
- Floris van Doorn, Herman Geuvers, and Freek Wiedijk. 2013. Explicit Convertibility Proofs in Pure Type Systems. In Proceedings of the Eighth ACM SIGPLAN International Workshop on Logical Frameworks & Meta-languages: Theory & Practice (LFMTP ’13). ACM, New York, NY, USA, 25–36. Google Scholar
Digital Library
- Dimitrios Vytiniotis, Simon Peyton Jones, Tom Schrijvers, and Martin Sulzmann. 2011. OutsideIn(X) Modular type inference with local assumptions. Journal of Functional Programming 21 (2011), 333–412. Issue Special Issue 4-5. Google Scholar
Digital Library
- Dimitrios Vytiniotis, Stephanie Weirich, and Simon Peyton Jones. 2008. FPH: First-class polymorphism for Haskell. In ICFP 2008: The 13th ACM SIGPLAN International Conference on Functional Programming. Victoria, BC, Canada, 295–306.Google Scholar
Digital Library
- 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 Scholar
Digital Library
- J.B. Wells. 1999. Typability and type checking in System F are equivalent and undecidable. Annals of Pure and Applied Logic 98, 1 (1999), 111 – 156. Google Scholar
Cross Ref
- A.K. Wright and M. Felleisen. 1994. A Syntactic Approach to Type Soundness. Inf. Comput. 115, 1 (Nov. 1994), 38–94. Google Scholar
Digital Library
- Yanpeng Yang, Xuan Bi, and Bruno C. d. S. Oliveira. 2016. Unified Syntax with Iso-types. Springer International Publishing, Cham, 251–270. Google Scholar
Cross Ref
- 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 Scholar
Digital Library
Index Terms
A specification for dependent types in Haskell
Recommendations
A role for dependent types in Haskell
Modern Haskell supports zero-cost coercions, a mechanism where types that share the same run-time representation may be freely converted between. To make sure such conversions are safe and desirable, this feature relies on a mechanism of roles to ...
Depending on types
ICFP '14: Proceedings of the 19th ACM SIGPLAN international conference on Functional programmingIs Haskell a dependently typed programming language? Should it be? GHC's many type-system features, such as Generalized Algebraic Datatypes (GADTs), datatype promotion, multiparameter type classes, and type families, give programmers the ability to ...
Depending on types
ICFP '14Is Haskell a dependently typed programming language? Should it be? GHC's many type-system features, such as Generalized Algebraic Datatypes (GADTs), datatype promotion, multiparameter type classes, and type families, give programmers the ability to ...






Comments