skip to main content
10.1145/1706299.1706341acmconferencesArticle/Chapter ViewAbstractPublication PagespoplConference Proceedingsconference-collections
research-article

Contracts made manifest

Published: 17 January 2010 Publication History

Abstract

Since Findler and Felleisen introduced higher-order contracts , many variants have been proposed. Broadly, these fall into two groups: some follow Findler and Felleisen in using latent contracts, purely dynamic checks that are transparent to the type system; others use manifest contracts, where refinement types record the most recent check that has been applied to each value. These two approaches are commonly assumed to be equivalent---different ways of implementing the same idea, one retaining a simple type system, and the other providing more static information. Our goal is to formalize and clarify this folklore understanding.
Our work extends that of Gronski and Flanagan, who defined a latent calculus λ C and a manifest calculus λ H , gave a translation φ from λ C to λ H , and proved that, if a λ C term reduces to a constant, then so does its φ-image. We enrich their account with a translation Ψ from λ H to λ C and prove an analogous theorem.
We then generalize the whole framework to dependent contracts , whose predicates can mention free variables. This extension is both pragmatically crucial, supporting a much more interesting range of contracts, and theoretically challenging. We define dependent versions of λ H and two dialects ("lax" and "picky") of λ C , establish type soundness---a substantial result in itself, for λ H ---and extend φ and Ψ accordingly. Surprisingly, the intuition that the latent and manifest systems are equivalent now breaks down: the extended translations preserve behavior in one direction but, in the other, sometimes yield terms that blame more.

References

[1]
Matthias Blume and David A. McAllester. Sound and complete models of contracts. Journal of Functional Programming, 16(4-5):375--414, 2006.
[2]
Olaf Chitil and Frank Huch. Monadic, prompt lazy assertions in haskell. In APLAS, pages 38--53, 2007.
[3]
Robert Bruce Findler. Contracts as pairs of projections. In Symposium on Logic Programming, pages 226--241, 2006.
[4]
Robert Bruce Findler and Matthias Felleisen. Contracts for higher-order functions. In International Conference on Functional Programming (ICFP), pages 48--59, 2002.
[5]
Cormac Flanagan. Hybrid type checking. In POPL, pages 245--256, 2006.
[6]
Jessica Gronski and Cormac Flanagan. Unifying hybrid types and contracts. In Trends in Functional Programming (TFP), 2007.
[7]
Jessica Gronski, Kenneth Knowles, Aaron Tomb, Stephen N. Freund, and Cormac Flanagan. Sage: Hybrid checking for flexible specifications. In Scheme and Functional Programming Workshop, pages 93--104, 2006.
[8]
Arjun Guha, Jacob Matthews, Robert Bruce Findler, and Shriram Krishnamurthi. Relationally-parametric polymorphic contracts. In DLS, pages 29--40, 2007.
[9]
Ralf Hinze, Johan Jeuring, and Andres L¨oh. Typed contracts for functional programming. In Functional and Logic Programming (FLOPS), pages 208--225, 2006.
[10]
Kenneth Knowles and Cormac Flanagan. Hybrid type checking. To appear in TOPLAS., 2009.
[11]
Bertrand Meyer. Eiffel: the language. Prentice-Hall, Inc., 1992. ISBN 0-13-247925-7.
[12]
Xinming Ou, Gang Tan, Yitzhak Mandelbaum, and DavidWalker. Dynamic typing with dependent types. In IFIP TCS, pages 437--450, 2004.
[13]
Sam Tobin-Hochstadt and Matthias Felleisen. The design and implementation of typed scheme. In Principles of Programming Languages (POPL), pages 395--406, 2008.
[14]
Philip Wadler and Robert Bruce Findler. Well-typed programs can't be blamed. In Workshop on Scheme and Functional Programming, 2007.
[15]
Philip Wadler and Robert Bruce Findler. Well-typed programs can't be blamed. In European Symposium on Programming (ESOP), pages 1--16, 2009.
[16]
Dana N. Xu, Simon Peyton Jones, and Koen Claessen. Static contract checking for haskell. In Principles of Programming Languages (POPL), pages 41--52, 2009.

Cited By

View all

Recommendations

Comments

Information & Contributors

Information

Published In

cover image ACM Conferences
POPL '10: Proceedings of the 37th annual ACM SIGPLAN-SIGACT symposium on Principles of programming languages
January 2010
520 pages
ISBN:9781605584799
DOI:10.1145/1706299
  • cover image ACM SIGPLAN Notices
    ACM SIGPLAN Notices  Volume 45, Issue 1
    POPL '10
    January 2010
    500 pages
    ISSN:0362-1340
    EISSN:1558-1160
    DOI:10.1145/1707801
    Issue’s Table of Contents
Permission to make digital or hard copies of all or part of this work for personal or classroom use is granted without fee provided that copies are not made or distributed for profit or commercial advantage and that copies bear this notice and the full citation on the first page. Copyrights for components of this work owned by others than ACM must be honored. Abstracting with credit is permitted. To copy otherwise, or republish, to post on servers or to redistribute to lists, requires prior specific permission and/or a fee. Request permissions from [email protected]

Sponsors

In-Cooperation

Publisher

Association for Computing Machinery

New York, NY, United States

Publication History

Published: 17 January 2010

Permissions

Request permissions for this article.

Check for updates

Author Tags

  1. blame
  2. contract
  3. dynamic checking
  4. postcondition
  5. precondition
  6. refinement type
  7. translation

Qualifiers

  • Research-article

Conference

POPL '10
Sponsor:

Acceptance Rates

Overall Acceptance Rate 824 of 4,130 submissions, 20%

Upcoming Conference

POPL '25

Contributors

Other Metrics

Bibliometrics & Citations

Bibliometrics

Article Metrics

  • Downloads (Last 12 months)16
  • Downloads (Last 6 weeks)3
Reflects downloads up to 23 Dec 2024

Other Metrics

Citations

Cited By

View all

View Options

Login options

View options

PDF

View or Download as a PDF file.

PDF

eReader

View online with eReader.

eReader

Media

Figures

Other

Tables

Share

Share

Share this Publication link

Share on social media