skip to main content

The root cause of blame: contracts for intersection and union types

Published:24 October 2018Publication History
Skip Abstract Section

Abstract

Gradual typing has emerged as the tonic for programmers with a thirst for a blend of static and dynamic typing. Contracts provide a lightweight form of gradual typing as they can be implemented as a library, rather than requiring a gradual type system.

Intersection and union types are well suited to static and dynamic languages: intersection encodes overloaded functions; union encodes uncertain data arising from branching code. We extend the untyped lambda calculus with contracts for monitoring higher-order intersection and union types, for the first time giving a uniform treatment to both. Each operator requires a single reduction rule that does not depend on the constituent types or the context of the operator.

We present a new method for defining contract satisfaction based on blame behaviour. A value positively satisfies a type if applying a contract of that type can never elicit positive blame. A continuation negatively satisfies a type if applying a contract of that type can never elicit negative blame. We supplement our definition of satisfaction with a series of monitoring properties that satisfying values and continuations should have.

Skip Supplemental Material Section

Supplemental Material

a134-williams.webm

References

  1. Amal Ahmed, Dustin Jamner, Jeremy G. Siek, and Philip Wadler. 2017. Theorems for Free for Free: Parametricity, With and Without Types. In ACM International Conference on Functional Programming (ICFP).Google ScholarGoogle Scholar
  2. Franco Barbanera and Mariangiola Dezani-Ciancaglini. 1991. Intersection and Union Types. In Theoretical Aspects of Computer Software, Takayasu Ito and Albert R. Meyer (Eds.). Springer Berlin Heidelberg. Google ScholarGoogle ScholarDigital LibraryDigital Library
  3. Gavin Bierman, Martín Abadi, and Mads Torgersen. 2014. Understanding TypeScript. In European Conference on ObjectOriented Programming (ECOOP). Google ScholarGoogle ScholarDigital LibraryDigital Library
  4. Matthias Blume and David McAllester. 2006. Sound and complete models of contracts. Journal of Functional Programming 16, 4-5 (2006), 375–414. Google ScholarGoogle ScholarDigital LibraryDigital Library
  5. Giuseppe Castagna and Victor Lanvin. 2017. Gradual Typing with Union and Intersection Types. In ACM International Conference on Functional Programming (ICFP).Google ScholarGoogle Scholar
  6. Avik Chaudhuri, Panagiotis Vekris, Sam Goldman, Marshall Roch, and Gabriel Levi. 2017. Fast and Precise Type Checking for JavaScript. In ACM Conference on Object-Oriented Programming: Systems, Languages, and Applications (OOPSLA).Google ScholarGoogle Scholar
  7. Mario Coppo and Mariangiola Dezani-Ciancaglini. 1978. A new type assignment for λ-terms. 19 (1978), 139–156.Google ScholarGoogle Scholar
  8. Rowan Davies and Frank Pfenning. 2000. Intersection Types and Computational Effects. In ACM International Conference on Functional Programming (ICFP). Google ScholarGoogle ScholarDigital LibraryDigital Library
  9. Christos Dimoulas and Matthias Felleisen. 2011. On contract satisfaction in a higher-order world. ACM Transactions on Programming Languages and Systems (TOPLAS) 33, 5 (2011), 16. Google ScholarGoogle ScholarDigital LibraryDigital Library
  10. Christos Dimoulas, Robert Bruce Findler, Cormac Flanagan, and Matthias Felleisen. 2011. Correct Blame for Contracts: No More Scapegoating. In ACM Symposium on Principles of Programming Languages (POPL). Google ScholarGoogle ScholarDigital LibraryDigital Library
  11. Christos Dimoulas, Sam Tobin-Hochstadt, and Matthias Felleisen. 2012. Complete Monitors for Behavioral Contracts. In European Symposium on Programming (ESOP). Google ScholarGoogle ScholarDigital LibraryDigital Library
  12. Joshua Dunfield and Frank Pfenning. 2003. Type Assignment for Intersections and Unions in Call-by-Value Languages. In Foundations of Software Science and Computation Structures. Google ScholarGoogle ScholarDigital LibraryDigital Library
  13. Robert Bruce Findler and Matthias Blume. 2006. Contracts as Pairs of Projections. In International Symposium on Functional and Logic Programming (FLOPS), Masami Hagiya and Philip Wadler (Eds.). Google ScholarGoogle ScholarDigital LibraryDigital Library
  14. Robert Bruce Findler, Matthias Blume, and Matthias Felleisen. 2004. An investigation of contracts as projections. University of Chicago Technical Report, TR-2004-02 (2004).Google ScholarGoogle Scholar
  15. Robert Bruce Findler and Matthias Felleisen. 2002. Contracts for Higher-order Functions. In ACM International Conference on Functional Programming (ICFP). Google ScholarGoogle ScholarDigital LibraryDigital Library
  16. Ronald Garcia, Alison M. Clark, and Éric Tanter. 2016. Abstracting Gradual Typing. In ACM Symposium on Principles of Programming Languages (POPL). Google ScholarGoogle ScholarDigital LibraryDigital Library
  17. Arjun Guha, Jacob Matthews, Robert Bruce Findler, and Shriram Krishnamurthi. 2007. Relationally-parametric Polymorphic Contracts. In Dynamic Languages Symposium (DLS). Google ScholarGoogle ScholarDigital LibraryDigital Library
  18. Atsushi Igarashi, Peter Thiemann, Vasco T. Vasconcelos, and Philip Wadler. 2017b. Gradual Session Types. In ACM International Conference on Functional Programming (ICFP).Google ScholarGoogle Scholar
  19. Yuu Igarashi, Taro Sekiyama, and Atsushi Igarashi. 2017a. On Polymorphic Gradual Typing. In ACM International Conference on Functional Programming (ICFP).Google ScholarGoogle Scholar
  20. Matthias Keil and Peter Thiemann. 2015a. Blame assignment for higher-order contracts with intersection and union. In ACM International Conference on Functional Programming (ICFP). Google ScholarGoogle ScholarDigital LibraryDigital Library
  21. Matthias Keil and Peter Thiemann. 2015b. TreatJS: Higher-Order Contracts for JavaScripts. In European Conference on Object-Oriented Programming (ECOOP) (Leibniz International Proceedings in Informatics (LIPIcs)). 28–51.Google ScholarGoogle Scholar
  22. Bertrand Meyer. 1988. Object-Oriented Software Construction. Prentice-Hall, Inc. Google ScholarGoogle ScholarDigital LibraryDigital Library
  23. Bertrand Meyer. 1992. Eiffel: The Language. Prentice-Hall, Inc. Google ScholarGoogle ScholarDigital LibraryDigital Library
  24. Benjamin C. Pierce. 1993. Intersection Types and Bounded Polymorphism. In Typed Lambda Calculi and Applications. Springer Berlin Heidelberg. Google ScholarGoogle ScholarDigital LibraryDigital Library
  25. Jeremy G. Siek and Walid Taha. 2006. Gradual Typing for Functional Languages. In Scheme and Functional Programming Workshop (Scheme).Google ScholarGoogle Scholar
  26. Jeremy G. Siek and Sam Tobin-Hochstadt. 2016. The Recursive Union of Some Gradual Types. Springer International Publishing.Google ScholarGoogle Scholar
  27. Jeremy G. Siek, Michael M. Vitousek, Matteo Cimini, and John Tang Boyland. 2015a. Refined Criteria for Gradual Typing. In 1st Summit on Advances in Programming Languages (SNAPL 2015) (Leibniz International Proceedings in Informatics (LIPIcs)).Google ScholarGoogle Scholar
  28. Jeremy G. Siek, Michael M. Vitousek, Matteo Cimini, Sam Tobin-Hochstadt, and Ronald Garcia. 2015b. Monotonic References for Efficient Gradual Typing. In European Symposium on Programming (ESOP). Google ScholarGoogle ScholarDigital LibraryDigital Library
  29. Cameron Swords, Amr Sabry, and Sam Tobin-Hochstadt. 2018. An extended account of contract monitoring strategies as patterns of communication. Journal of Functional Programming 28 (2018), e4.Google ScholarGoogle ScholarCross RefCross Ref
  30. Sam Tobin-Hochstadt and Matthias Felleisen. 2006. Interlanguage Migration: From Scripts to Programs. In Dynamic Languages Symposium (DLS). Google ScholarGoogle ScholarDigital LibraryDigital Library
  31. Matías Toro and Éric Tanter. 2017. A Gradual Interpretation of Union Types. In Static Analysis.Google ScholarGoogle Scholar
  32. Jesse A. Tov and Riccardo Pucella. 2010. Stateful Contracts for Affine Types. In European Symposium on Programming (ESOP). Google ScholarGoogle ScholarDigital LibraryDigital Library
  33. Philip Wadler. 2015. A Complement to Blame. In SNAPL.Google ScholarGoogle Scholar
  34. Philip Wadler and Robert Bruce Findler. 2009. Well-Typed Programs Can’t Be Blamed. In European Symposium on Programming (ESOP). 1–16. Google ScholarGoogle ScholarDigital LibraryDigital Library
  35. Dana N. Xu, Simon Peyton Jones, and Koen Claessen. 2009. Static Contract Checking for Haskell. In ACM Symposium on Principles of Programming Languages (POPL). Google ScholarGoogle ScholarDigital LibraryDigital Library

Index Terms

  1. The root cause of blame: contracts for intersection and union types

        Recommendations

        Comments

        Login options

        Check if you have access through your login credentials or your institution to get full access on this article.

        Sign in

        Full Access

        PDF Format

        View or Download as a PDF file.

        PDF

        eReader

        View online with eReader.

        eReader
        About Cookies On This Site

        We use cookies to ensure that we give you the best experience on our website.

        Learn more

        Got it!