Blame for all

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.

[1]  Satish R. Thatte,et al.  Type Inference with Partial Types , 1988, Theor. Comput. Sci..

[2]  Fritz Henglein,et al.  Dynamic Typing: Syntax and Proof Theory , 1994, Sci. Comput. Program..

[3]  Stephen N. Freund,et al.  Sage: Hybrid Checking for Flexible Specifications , 2006 .

[4]  James H. Morris,et al.  Types are not sets , 1973, POPL.

[5]  Dan Grossman,et al.  Syntactic type abstraction , 2000, TOPL.

[6]  Philip Wadler,et al.  Well-Typed Programs Can't Be Blamed , 2009, ESOP.

[7]  Jan Vitek,et al.  Integrating typed and untyped code in a scripting language , 2010, POPL '10.

[8]  Matthias Felleisen,et al.  Contracts for higher-order functions , 2002, ICFP '02.

[9]  Robert Bruce Findler,et al.  Operational semantics for multi-language programs , 2007, POPL '07.

[10]  Simon L. Peyton Jones,et al.  A short cut to deforestation , 1993, FPCA '93.

[11]  Jeremy G. Siek Gradual Typing for Functional Languages , 2006 .

[12]  Amal Ahmed,et al.  Parametric Polymorphism through Run-Time Sealing or, Theorems for Low, Low Prices! , 2008, ESOP.

[13]  Georg Neis,et al.  Non-parametric parametricity , 2011, J. Funct. Program..

[14]  Andrew K. Wright Simple imperative polymorphism , 1995, LISP Symb. Comput..

[15]  Walid Taha,et al.  Gradual Typing for Objects , 2007, ECOOP.

[16]  Benjamin C. Pierce,et al.  Relating Cryptography and Polymorphism , 2000 .

[17]  Robert Harper,et al.  Practical Foundations for Programming Languages , 2012 .

[18]  David Walker,et al.  Dynamic Typing with Dependent Types , 2004, IFIP TCS.

[19]  John C. Reynolds,et al.  Types, Abstraction and Parametric Polymorphism , 1983, IFIP Congress.

[20]  Simon L. Peyton Jones,et al.  System F with type equality coercions , 2007, TLDI '07.

[21]  Philip Wadler,et al.  Blame for all , 2009, ECOOP 2009.

[22]  Philip Wadler,et al.  Theorems for free! , 1989, FPCA.

[23]  Fritz Henglein Dynamic Typing , 1992, ESOP.

[24]  Sam Tobin-Hochstadt,et al.  Interlanguage migration: from scripts to programs , 2006, OOPSLA '06.

[25]  Cormac Flanagan,et al.  Hybrid type checking , 2006, POPL '06.

[26]  Robert Bruce Findler,et al.  Relationally-parametric polymorphic contracts , 2007, DLS '07.

[27]  Andreas Rossberg,et al.  Generativity and dynamic opacity for abstract types , 2003, PPDP '03.

[28]  Martín Abadi,et al.  Dynamic typing in a statically-typed language , 1989, POPL '89.