Union and intersection contracts are hard, actually

Union and intersection types are a staple of gradually typed languages such as TypeScript. While it's long been recognized that union and intersection types are difficult to verify statically, it may appear at first that the dynamic part of gradual typing is actually pretty simple. It turns out however, that in presence of higher-order contracts union and intersection are deceptively difficult. The literature on higher-order contracts with union and intersection, while keenly aware of the fact, doesn't really explain why. We point and illustrate the problems and trade-offs inherent to union and intersection contracts, via example and a survey of the literature.

[1]  Giuseppe Castagna,et al.  Gradual typing: a new perspective , 2019, Proc. ACM Program. Lang..

[2]  Philip Wadler,et al.  The root cause of blame: contracts for intersection and union types , 2018, Proc. ACM Program. Lang..

[3]  Giuseppe Castagna,et al.  Gradual typing with union and intersection types , 2017, Proc. ACM Program. Lang..

[4]  Simon L. Peyton Jones,et al.  Let-floating: moving bindings to give faster programs , 1996, ICFP '96.

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

[6]  Giuseppe Castagna,et al.  Semantic subtyping: Dealing set-theoretically with function, union, intersection, and negation types , 2008, JACM.

[7]  Francisco Ortin,et al.  Union and intersection types to support both dynamic and static typing , 2011, Inf. Process. Lett..

[8]  Matías Toro,et al.  A Gradual Interpretation of Union Types , 2017, SAS.

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

[10]  Michael Greenberg,et al.  The Dynamic Practice and Static Theory of Gradual Typing , 2019, SNAPL.

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

[12]  Philip Wadler,et al.  Programming Languages and Systems , 2009 .

[13]  Bertrand Meyer,et al.  Eiffel: programming for reusability and extendibility , 1987, SIGP.

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

[15]  Peter Thiemann,et al.  Blame assignment for higher-order contracts with intersection and union , 2015, ICFP.