Abstract
Several programming languages are beginning to integrate static and dynamic typing, including Racket (formerly PLT Scheme), Perl 6, and C# 4.0 and the research languages Sage (Gronski, Knowles, Tomb, Freund, and Flanagan, 2006) and Thorn (Wrigstad, Eugster, Field, Nystrom, and Vitek, 2009). However, an important open question remains, which is how to add parametric polymorphism to languages that combine static and dynamic typing. We present a system that permits a value of dynamic type to be cast to a polymorphic type and vice versa, with relational parametricity enforced by a kind of dynamic sealing along the lines proposed by Matthews and Ahmed (2008) and Neis, Dreyer, and Rossberg (2009). Our system includes a notion of blame, which allows us to show that when casting between a more-precise type and a less-precise type, any cast failures are due to the less-precisely-typed portion of the program. We also show that a cast from a subtype to its supertype cannot fail.
Supplemental Material
References
- Martin Abadi, Luca Cardelli, Benjamin Pierce, and Gordon Plotkin. Dynamic typing in a statically typed language. ACM Transactions on Programming Languages and Systems, 13 (2): 237--268, April 1991. Google Scholar
Digital Library
- Amal Ahmed, Jacob Matthews, Robert Bruce Findler, and Philip Wadler. Blame for all. In Workshop on Script-to-Program Evolution (STOP), pages 1--13, 2009. Google Scholar
Digital Library
- Robert Bruce Findler and Matthias Felleisen. Contracts for higher-order functions. In ACM International Conference on Functional Programming (ICFP), pages 48--59, October 2002. Google Scholar
Digital Library
- Andrew Gill, John Launchbury, and Simon L. Peyton Jones. A short cut to deforestation. In ACM Conference on Functional Programming Languages and Computer Architecture (FPCA), pages 223--232, September 1993. Google Scholar
Digital Library
- Jessica Gronski, Kenneth Knowles, Aaron Tomb, Stephen N. Freund, and Cormac Flanagan. Sage: Hybrid checking for flexible specifications. In Scheme and Functional Programming Workshop (Scheme), pages 93--104, September 2006.Google Scholar
- Dan Grossman, Greg Morrisett, and Steve Zdancewic. Syntactic type abstraction. ACM Transactions on Programming Languages and Systems, 22 (6): 1037--1080, November 2000. Google Scholar
Digital Library
- Arjun Guha, Jacob Matthews, Robert Bruce Findler, and Shriram Krishnamurthi. Relationally-parametric polymorphic contracts. In Dynamic Languages Symposium (DLS), pages 29--40, 2007. Google Scholar
Digital Library
- Robert Harper. Practical Foundations for Programming Languages. 2007. Working Draft.Google Scholar
- Fritz Henglein. Dynamic typing: Syntax and proof theory. Science of Computer Programming, 22 (3): 197--230, 1994. Google Scholar
Digital Library
- Jacob Matthews and Amal Ahmed. Parametric polymorphism through run-time sealing. In European Symposium on Programming (ESOP), pages 16--31, 2008. Google Scholar
Digital Library
- Jacob Matthews and Robert Bruce Findler. Operational semantics for multi-language programs. In ACM Symposium on Principles of Programming Languages (POPL), pages 3--10, January 2007. Google Scholar
Digital Library
- James H. Morris, Jr. Types are not sets. In ACM Symposium on Principles of Programming Languages (POPL), pages 120--124, October 1973. Google Scholar
Digital Library
- Georg Neis, Derek Dreyer, and Andreas Rossberg. Non-parametric parametricity. In ACM International Conference on Functional Programming (ICFP), pages 135--148, September 2009. Google Scholar
Digital Library
- Xinming Ou, Gang Tan, Yitzhak Mandelbaum, and David Walker. Dynamic typing with dependent types. In IFIP International Conference on Theoretical Computer Science, pages 437--450, August 2004.Google Scholar
Cross Ref
- Benjamin Pierce and Eijiro Sumii. Relating cryptography and polymorphism. Manuscript, 2000. URL www.cis.upenn.edu/ bcpierce/papers/infohide.ps.Google Scholar
- John Reynolds. Types, abstraction, and parametric polymorphism. In R. E. A. Mason, editor, Information Processing, pages 513--523. North-Holland, 1983.Google Scholar
- Andreas Rossberg. Generativity and dynamic opacity for abstract types. In ACM Conference on Principles and Practice of Declarative Programming (PPDP), pages 241--252, 2003. Google Scholar
Digital Library
- Jeremy G. Siek and Walid Taha. Gradual typing for functional languages. In Scheme and Functional Programming Workshop (Scheme), pages 81--92, September 2006.Google Scholar
- Martin Sulzmann, Manuel M. T. Chakravarty, Simon Peyton Jones, and Kevin Donnelly. System F with type equality coercions. In ACM Workshop on Types in Languages Design and Implementation (TLDI), pages 53--66, 2007. Google Scholar
Digital Library
- Satish Thatte. Type inference with partial types. In International Colloquium on Automata, Languages and Programming (ICALP), volume 317 of phLecture Notes in Computer Science, pages 615--629. Springer-Verlag, 1988. Google Scholar
Digital Library
- Sam Tobin-Hochstadt and Matthias Felleisen. Interlanguage migration: From scripts to programs. In Dynamic Languages Symposium (DLS), pages 964--974, October 2006. Google Scholar
Digital Library
- Philip Wadler and Robert Bruce Findler. Well-typed programs can't be blamed. In European Symposium on Programming (ESOP), pages 1--16, March 2009. Google Scholar
Digital Library
- Andrew K. Wright. Simple imperative polymorphism. Higher-Order and Symbolic Computation, 8 (4): 343--355, Dec. 1995. Google Scholar
Digital Library
- Tobias Wrigstad, Francesco Zappa Nardelli, Sylvain Lebresne, Johan Östlund, and Jan Vitek. Integrating typed and untyped code in a scripting language. In ACM Symposium on Principles of Programming Languages (POPL), pages 377--388, 2010. Google Scholar
Digital Library
Index Terms
Blame for all






Comments