Skip to main content

Advertisement

SpringerLink
  • Log in
Book cover

European Symposium on Programming

ESOP 2011: Programming Languages and Systems pp 18–37Cite as

  1. Home
  2. Programming Languages and Systems
  3. Conference paper
Polymorphic Contracts

Polymorphic Contracts

  • João Filipe Belo17,
  • Michael Greenberg17,
  • Atsushi Igarashi18 &
  • …
  • Benjamin C. Pierce17 
  • Conference paper
  • 933 Accesses

  • 4 Citations

Part of the Lecture Notes in Computer Science book series (LNTCS,volume 6602)

Abstract

Manifest contracts track precise properties by refining types with predicates—e.g., {x : Int |x > 0 } denotes the positive integers. Contracts and polymorphism make a natural combination: programmers can give strong contracts to abstract types, precisely stating pre- and post-conditions while hiding implementation details— for example, an abstract type of stacks might specify that the pop operation has input type {x :α Stack |not ( empty x )} . We formalize this combination by defining FH, a polymorphic calculus with manifest contracts, and establishing fundamental properties including type soundness and relational parametricity. Our development relies on a significant technical improvement over earlier presentations of contracts: instead of introducing a denotational model to break a problematic circularity between typing, subtyping, and evaluation, we develop the metatheory of contracts in a completely syntactic fashion, omitting subtyping from the core system and recovering it post facto as a derived property.

Keywords

  • contracts
  • refinement types
  • preconditions
  • postconditions
  • dynamic checking
  • parametric polymorphism
  • abstract datatypes
  • syntactic proof
  • logical relations
  • subtyping

Download conference paper PDF

References

  1. PLT Racket Contracts, http://pre.plt-scheme.org/docs/html/guide/contracts.html

  2. Ahmed, A., Findler, R.B., Matthews, J., Wadler, P.: Blame for all. In: Workshop on Script-to-Program Evolution, STOP (2009)

    Google Scholar 

  3. Ahmed, A., Findler, R.B., Siek, J., Wadler, P.: Blame for all. In: Principles of Programming Languages, POPL (2011)

    Google Scholar 

  4. Aspinall, D., Compagnoni, A.: Subtyping dependent types. Theor. Comput. Sci. 266(1-2), 273–309 (2001)

    CrossRef  MathSciNet  MATH  Google Scholar 

  5. Findler, R.B., Felleisen, M.: Contracts for higher-order functions. In: International Conference on Functional Programming (ICFP), pp. 48–59 (2002)

    Google Scholar 

  6. Flanagan, C.: Hybrid type checking. In: POPL, pp. 245–256 (2006)

    Google Scholar 

  7. Greenberg, M., Pierce, B.C., Weirich, S.: Contracts made manifest. In: Principles of Programming Languages, POPL 2010 (2010)

    Google Scholar 

  8. Gronski, J., Flanagan, C.: Unifying hybrid types and contracts. In: Trends in Functional Programming, TFP (2007)

    Google Scholar 

  9. Guha, A., Matthews, J., Findler, R.B., Krishnamurthi, S.: Relationally-parametric polymorphic contracts. In: DLS, pp. 29–40 (2007)

    Google Scholar 

  10. Knowles, K., Flanagan, C.: Hybrid type checking (2010) (to appear in TOPLAS)

    Google Scholar 

  11. Matthews, J., Ahmed, A.: Parametric polymorphism through run-time sealing or, theorems for low, low prices! In: Gairing, M. (ed.) ESOP 2008. LNCS, vol. 4960, pp. 16–31. Springer, Heidelberg (2008)

    CrossRef  Google Scholar 

  12. Ou, X., Tan, G., Mandelbaum, Y., Walker, D.: Dynamic typing with dependent types. In: IFIP TCS, pp. 437–450 (2004)

    Google Scholar 

  13. Pierce, B., Sumii, E.: Relating cryptography and polymorphism (July 2000)

    Google Scholar 

  14. Pitts, A.M.: Typed operational reasoning. In: Pierce, B.C. (ed.) Advanced Topics in Types and Programming Languages, ch. 7, pp. 245–289. MIT Press, Cambridge (2005)

    Google Scholar 

  15. Siek, J.G., Taha, W.: Gradual typing for functional languages. In: Scheme and Functional Programming Workshop (September 2006)

    Google Scholar 

  16. Strickland, T.S., Tobin-Hochstadt, S., Felleisen, M.: Practical variable-arity polymorphism. In: Castagna, G. (ed.) ESOP 2009. LNCS, vol. 5502, pp. 32–46. Springer, Heidelberg (2009)

    CrossRef  Google Scholar 

  17. Wadler, P.: Theorems for free! In: Proceedings of ACM Conference on Functional Programming and Computer Architecture (FPCA 1989), pp. 347–359, London, UK (September 1989)

    Google Scholar 

  18. Wadler, P., Findler, R.B.: Well-typed programs can’t be blamed. In: Castagna, G. (ed.) ESOP 2009. LNCS, vol. 5502, pp. 1–16. Springer, Heidelberg (2009)

    CrossRef  Google Scholar 

  19. Wright, A.K., Felleisen, M.: A syntactic approach to type soundness. Information and Computation 115, 38–94 (1992)

    CrossRef  MathSciNet  MATH  Google Scholar 

Download references

Author information

Authors and Affiliations

  1. University of Pennsylvania, USA

    João Filipe Belo, Michael Greenberg & Benjamin C. Pierce

  2. Kyoto University, Japan

    Atsushi Igarashi

Authors
  1. João Filipe Belo
    View author publications

    You can also search for this author in PubMed Google Scholar

  2. Michael Greenberg
    View author publications

    You can also search for this author in PubMed Google Scholar

  3. Atsushi Igarashi
    View author publications

    You can also search for this author in PubMed Google Scholar

  4. Benjamin C. Pierce
    View author publications

    You can also search for this author in PubMed Google Scholar

Editor information

Editors and Affiliations

  1. Facultad de Informatica (UPM), IMDEA Software, Campus Montegancedo, 28660, Boadilla del Monte, Madrid, Spain

    Gilles Barthe

Rights and permissions

Reprints and Permissions

Copyright information

© 2011 Springer-Verlag Berlin Heidelberg

About this paper

Cite this paper

Belo, J.F., Greenberg, M., Igarashi, A., Pierce, B.C. (2011). Polymorphic Contracts. In: Barthe, G. (eds) Programming Languages and Systems. ESOP 2011. Lecture Notes in Computer Science, vol 6602. Springer, Berlin, Heidelberg. https://doi.org/10.1007/978-3-642-19718-5_2

Download citation

  • .RIS
  • .ENW
  • .BIB
  • DOI: https://doi.org/10.1007/978-3-642-19718-5_2

  • Publisher Name: Springer, Berlin, Heidelberg

  • Print ISBN: 978-3-642-19717-8

  • Online ISBN: 978-3-642-19718-5

  • eBook Packages: Computer ScienceComputer Science (R0)

Share this paper

Anyone you share the following link with will be able to read this content:

Sorry, a shareable link is not currently available for this article.

Provided by the Springer Nature SharedIt content-sharing initiative

Over 10 million scientific documents at your fingertips

Switch Edition
  • Academic Edition
  • Corporate Edition
  • Home
  • Impressum
  • Legal information
  • Privacy statement
  • California Privacy Statement
  • How we use cookies
  • Manage cookies/Do not sell my data
  • Accessibility
  • FAQ
  • Contact us
  • Affiliate program

Not logged in - 3.238.250.73

Not affiliated

Springer Nature

© 2023 Springer Nature Switzerland AG. Part of Springer Nature.