Blame and coercion: together again for the first time

C#, Dart, Pyret, Racket, TypeScript, VB: many recent languages integrate dynamic and static types via gradual typing. We systematically develop three calculi for gradual typing and the relations between them, building on and strengthening previous work. The calculi are: λB, based on the blame calculus of Wadler and Findler (2009); λC, inspired by the coercion calculus of Henglein (1994); λS inspired by the space-efficient calculus of Herman, Tomb, and Flanagan (2006) and the threesome calculus of Siek and Wadler (2010). While λB is little changed from previous work, λC and λS are new. Together, λB, λC, and λS provide a coherent foundation for design, implementation, and optimisation of gradual types. We define translations from λB to λC and from λC to λS. Much previous work lacked proofs of correctness or had weak correctness criteria; here we demonstrate the strongest correctness criterion one could hope for, that each of the translations is fully abstract. Each of the calculi reinforces the design of the others: λC has a particularly simple definition, and the subtle definition of blame safety for λB is justified by the simple definition of blame safety for λC. Our calculus λS is implementation-ready: the first space-efficient calculus that is both straightforward to implement and easy to understand. We give two applications: first, using full abstraction from λC to λS to validate the challenging part of full abstraction between λB and λC; and, second, using full abstraction from λB to λS to easily establish the Fundamental Property of Casts, which required a custom bisimulation and six lemmas in earlier work.

[1]  Martín Abadi,et al.  Understanding TypeScript , 2014, ECOOP.

[2]  Sam Tobin-Hochstadt,et al.  The design and implementation of typed scheme , 2008, POPL '08.

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

[4]  Jan Vitek,et al.  Concrete Types for TypeScript , 2015, ECOOP.

[5]  Juan Chen,et al.  Gradual typing embedded securely in JavaScript , 2014, POPL.

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

[7]  Walid Taha,et al.  Exploring the Design Space of Higher-Order Casts , 2009, ESOP.

[8]  Gavin M. Bierman,et al.  Safe & Efficient Gradual Typing for TypeScript , 2015, POPL.

[9]  Matthias Felleisen,et al.  Correct blame for contracts: no more scapegoating , 2011, POPL '11.

[10]  Robert W. Floyd,et al.  Assigning Meanings to Programs , 1993 .

[11]  Philip Wadler,et al.  A Complement to Blame , 2015, SNAPL.

[12]  Philip Wadler,et al.  Threesomes, with and without blame , 2010, POPL '10.

[13]  Sam Tobin-Hochstadt,et al.  Chaperones and impersonators: run-time support for reasonable interposition , 2012, OOPSLA '12.

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

[15]  Gavin M. Bierman,et al.  Adding Dynamic Types to C# , 2010, ECOOP.

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

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

[18]  Philip Wadler,et al.  Blame for all , 2011, POPL '11.

[19]  Benjamin C. Pierce,et al.  Contracts made manifest , 2010, POPL '10.

[20]  Jeremy G. Siek,et al.  Interpretations of the gradually-typed lambda calculus , 2012, Scheme '12.

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

[22]  簡聰富,et al.  物件導向軟體之架構(Object-Oriented Software Construction)探討 , 1989 .

[23]  Cormac Flanagan,et al.  Temporal higher-order contracts , 2011, ICFP.

[24]  Nick Benton,et al.  Undoing Dynamic Typing (Declarative Pearl) , 2008, FLOPS.

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

[26]  Benjamin C. Pierce,et al.  Manifest contracts , 2013 .

[27]  Ronald Garcia,et al.  Calculating threesomes, with blame , 2013, ICFP.

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

[29]  Sam Tobin-Hochstadt,et al.  Complete Monitors for Behavioral Contracts , 2012, ESOP.

[30]  Peter Thiemann,et al.  Session Types with Gradual Typing , 2014, TGC.

[31]  John Tang Boyland,et al.  Refined Criteria for Gradual Typing , 2015, SNAPL.

[32]  Cormac Flanagan,et al.  Space-efficient gradual typing , 2010, High. Order Symb. Comput..

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

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

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

[36]  Olaf Chitil,et al.  Practical typed lazy contracts , 2012, ICFP.

[37]  Ralf Hinze,et al.  Typed Contracts for Functional Programming , 2006, FLOPS.

[38]  Lauretta O. Osho,et al.  Axiomatic Basis for Computer Programming , 2013 .

[39]  Raymond Turner,et al.  Programming Language Specification , 2009 .