Abstract
The design space for type systems that support impredicative instantiation is extremely complicated. One needs to strike a balance between expressiveness, simplicity for both the end programmer and the type system implementor, and how easily the system can be integrated with other advanced type system concepts. In this paper, we propose a new point in the design space, which we call guarded impredicativity. Its key idea is that impredicative instantiation in an application is allowed for type variables that occur under a type constructor. The resulting type system has a clean declarative specification — making it easy for programmers to predict what will type and what will not —, allows for a smooth integration with GHC’s OutsideIn(X) constraint solving framework, while giving up very little in terms of expressiveness compared to systems like HMF, HML, FPH and MLF. We give a sound and complete inference algorithm, and prove a principal type property for our system.
Supplemental Material
- Didier Le Botlan and Didier Rémy. 2003. MLF: raising ML to the power of system F. In Proceedings of the Eighth ACM SIGPLAN International Conference on Functional Programming, ICFP 2003, Uppsala, Sweden, August 25-29, 2003, Colin Runciman and Olin Shivers (Eds.). ACM, 27-38. Google Scholar
Digital Library
- Didier Le Botlan and Didier Rémy. 2009. Recasting MLF. Inf. Comput. 207, 6 (2009), 726-785. Google Scholar
Digital Library
- Hubert Comon and Pierre Lescanne. 1988. Equational problems and disunification. Research Report RR-0904. INRIA. https://hal.inria.fr/inria-00075652Google Scholar
- Joshua Dunfield and Neelakantan R. Krishnaswami. 2013. Complete and easy bidirectional typechecking for higher-rank polymorphism. In ACM SIGPLAN International Conference on Functional Programming, ICFP'13, Boston, MA, USA - September 25 - 27, 2013, Greg Morrisett and Tarmo Uustalu (Eds.). ACM, 429-442. Google Scholar
Digital Library
- Richard A. Eisenberg, Stephanie Weirich, and Hamidhasan G. Ahmed. 2016. Visible Type Application. In Proceedings of the 25th European Symposium on Programming Languages and Systems - Volume 9632. Springer-Verlag New York, Inc., New York, NY, USA, 229-254. Google Scholar
Digital Library
- Bastiaan Heeren, Jurriaan Hage, and S. Doaitse Swierstra. 2003. Scripting the type inference process. SIGPLAN Notices 38, 9 (2003), 3-13. Google Scholar
Digital Library
- James Hook and Peter Thiemann (Eds.). 2008. Proceeding of the 13th ACM SIGPLAN international conference on Functional programming, ICFP 2008, Victoria, BC, Canada, September 20-28, 2008. ACM. Google Scholar
Cross Ref
- Daan Leijen. 2008. HMF: simple type inference for first-class polymorphism, See [7], 283-294. Google Scholar
Digital Library
- Daan Leijen. 2009. Flexible types: robust type inference for first-class polymorphism. In Proceedings of the 36th ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages, POPL 2009, Savannah, GA, USA, January 21-23, 2009, Zhong Shao and Benjamin C. Pierce (Eds.). ACM, 66-77. Google Scholar
Digital Library
- Daan Leijen and Andres Löh. 2005. Qualified types for MLF. 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, 144-155. Google Scholar
Digital Library
- J. W. O'Toole, Jr. and D. K. Gifford. 1989. Type Reconstruction with First-class Polymorphic Values. In Proceedings of the ACM SIGPLAN 1989 Conference on Programming Language Design and Implementation (PLDI '89). ACM, New York, NY, USA, 207-217. Google Scholar
Digital Library
- 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 (2007), 1-82. Google Scholar
Digital Library
- Frank Pfenning. 1988. Partial Polymorphic Type Inference and Higher-order Unification. In Proceedings of the 1988 ACM Conference on LISP and Functional Programming (LFP '88). ACM, New York, NY, USA, 153-163. Google Scholar
Digital Library
- François Pottier and Didier Rémy. 2005. The Essence of ML Type Inference. In Advanced Topics in Types and Programming Languages, Benjamin C. Pierce (Ed.). MIT Press, Chapter 10, 389-489. http://cristal.inria.fr/attapl/Google Scholar
- Didier Rémy. 1994. Programming Objects with ML-ART, an Extension to ML with Abstract and Record Types. In Proceedings of the International Conference on Theoretical Aspects of Computer Software (TACS '94). Springer-Verlag, London, UK, UK, 321-346. http://dl.acm.org/citation.cfm?id=645868.668492 Google Scholar
Digital Library
- Didier Rémy. 2005. Simple, Partial Type-inference for System F Based on Type-containment. In Proceedings of the Tenth ACM SIGPLAN International Conference on Functional Programming (ICFP '05). ACM, New York, NY, USA, 130-143. Google Scholar
Digital Library
- Didier Rémy and Boris Yakobowski. 2008. From ML to MLF: graphic type constraints with efficient type inference, See [7], 63-74. Google Scholar
Digital Library
- Claudio V. Russo and Dimitrios Vytiniotis. 2009. QML: Explicit Firstclass Polymorphism for ML. In Proceedings of the 2009 ACM SIGPLAN Workshop on ML (ML '09). ACM, New York, NY, USA, 3-14. Google Scholar
Digital Library
- Alejandro Serrano and Jurriaan Hage. 2016. Type Error Diagnosis for Embedded DSLs by Two-Stage Specialized Type Rules. In Programming Languages and Systems - 25th European Symposium on Programming, ESOP 2016, Held as Part of the European Joint Conferences on Theory and Practice of Software, ETAPS 2016, Eindhoven, The Netherlands, April 2-8, 2016, Proceedings (Lecture Notes in Computer Science), Peter Thiemann (Ed.), Vol. 9632. Springer, 672-698. Google Scholar
Digital Library
- Dimitrios Vytiniotis, Simon L. Peyton Jones, Tom Schrijvers, and Martin Sulzmann. 2011. OutsideIn(X): Modular type inference with local assumptions. J. Funct. Program. 21, 4-5 (2011), 333-412. Google Scholar
Digital Library
- Dimitrios Vytiniotis, Stephanie Weirich, and Simon L. Peyton Jones. 2006. Boxy types: inference for higher-rank types and impredicativity. In Proceedings of the 11th ACM SIGPLAN International Conference on Functional Programming, ICFP 2006, Portland, Oregon, USA, September 16-21, 2006, John H. Reppy and Julia L. Lawall (Eds.). ACM, 251-262. Google Scholar
Digital Library
- Dimitrios Vytiniotis, Stephanie Weirich, and Simon L. Peyton Jones. 2008. FPH: first-class polymorphism for Haskell, See [7], 295-306. Google Scholar
Digital Library
- J. B. Wells. 1993. Typability and Type Checking in the Second-Order Lambda-Calculus Are Equivalent and Undecidable. Technical Report. Boston, MA, USA. Google Scholar
- Danfeng Zhang, Andrew C. Myers, Dimitrios Vytiniotis, and Simon L. Peyton Jones. 2015. Diagnosing type errors with class. In Proceedings of the 36th ACM SIGPLAN Conference on Programming Language Design and Implementation, Portland, OR, USA, June 15-17, 2015, David Grove and Steve Blackburn (Eds.). ACM, 12-21. Google Scholar
Digital Library
Index Terms
Guarded impredicative polymorphism
Recommendations
Guarded impredicative polymorphism
PLDI 2018: Proceedings of the 39th ACM SIGPLAN Conference on Programming Language Design and ImplementationThe design space for type systems that support impredicative instantiation is extremely complicated. One needs to strike a balance between expressiveness, simplicity for both the end programmer and the type system implementor, and how easily the system ...
Type inference, principal typings, and let-polymorphism for first-class mixin modules
Proceedings of the tenth ACM SIGPLAN international conference on Functional programmingA mixin module is a programming abstraction that simultaneously generalizes λ-abstractions, records, and mutually recursive definitions. Although various mixin module type systems have been developed, no one has investigated principal typings or ...
Type inference, principal typings, and let-polymorphism for first-class mixin modules
ICFP '05: Proceedings of the tenth ACM SIGPLAN international conference on Functional programmingA mixin module is a programming abstraction that simultaneously generalizes λ-abstractions, records, and mutually recursive definitions. Although various mixin module type systems have been developed, no one has investigated principal typings or ...







Comments