skip to main content
10.1145/581478.581484acmconferencesArticle/Chapter ViewAbstractPublication PagesicfpConference Proceedingsconference-collections
Article

Contracts for higher-order functions

Published:17 September 2002Publication History

ABSTRACT

Assertions play an important role in the construction of robust software. Their use in programming languages dates back to the 1970s. Eiffel, an object-oriented programming language, wholeheartedly adopted assertions and developed the "Design by Contract" philosophy. Indeed, the entire object-oriented community recognizes the value of assertion-based contracts on methods.In contrast, languages with higher-order functions do not support assertion-based contracts. Because predicates on functions are, in general, undecidable, specifying such predicates appears to be meaningless. Instead, the functional languages community developed type systems that statically approximate interesting predicates.In this paper, we show how to support higher-order function contracts in a theoretically well-founded and practically viable manner. Specifically, we introduce λcon, a typed lambda calculus with assertions for higher-order functions. The calculus models the assertion monitoring system that we employ in DrScheme. We establish basic properties of the model (type soundness, etc.) and illustrate the usefulness of contract checking with examples from DrScheme's code base.We believe that the development of an assertion system for higher-order functions serves two purposes. On one hand, the system has strong practical potential because existing type systems simply cannot express many assertions that programmers would like to state. On the other hand, an inspection of a large base of invariants may provide inspiration for the direction of practical future type system research.

References

  1. AT&T Bell Labratories. Standard ML of New Jersey, 1993.]]Google ScholarGoogle Scholar
  2. Clinger, W. D. Proper tail recursion and space efficiency. In Proceedings of ACM SIGPLAN Conference on Programming Language Design and Implementation, pages 174--185, June 1998.]] Google ScholarGoogle ScholarDigital LibraryDigital Library
  3. Felleisen, M., R. B. Findler, M. Flatt and S. Krishnamurthi. How to Design Programs. MIT Press, 2001.]]Google ScholarGoogle Scholar
  4. Felleisen, M. and R. Hieb. The revised report on the syntactic theories of sequential control and state. In Theoretical Computer Science, pages 235--271, 1992.]] Google ScholarGoogle ScholarDigital LibraryDigital Library
  5. Findler, R. B., J. Clements, C. Flanagan, M. Flatt, S. Krishnamurthi, P. Steckler and M. Felleisen. DrScheme: A programming environment for Scheme. Journal of Functional Programming, 12(2):159--182, March 2002. A preliminary version of this paper appeared in PLILP 1997, LNCS volume 1292, pages 369--388.]] Google ScholarGoogle ScholarDigital LibraryDigital Library
  6. Findler, R. B. and M. Felleisen. Contracts for higher-order functions. Technical Report NU-CCS-02-05, Northeastern University, 2002.]]Google ScholarGoogle ScholarDigital LibraryDigital Library
  7. Findler, R. B. and M. Flatt. Modular object-oriented programming with units and mixins. In Proceedings of ACM SIGPLAN International Conference on Functional Programming, pages 94--104, September 1998.]] Google ScholarGoogle ScholarDigital LibraryDigital Library
  8. Flatt, M. PLT MzScheme: Language manual. Technical Report TR97-280, Rice University, 1997. http://www.plt-scheme.org/software/mzscheme/.]]Google ScholarGoogle Scholar
  9. Flatt, M. Composable and compilable macros: You want it when? In Proceedings of ACM SIGPLAN International Conference on Functional Programming, 2002.]] Google ScholarGoogle ScholarDigital LibraryDigital Library
  10. Flatt, M., S. Krishnamurthi and M. Felleisen. A programmer's reduction semantics for classes and mixins. Formal Syntax and Semantics of Java, 1523:241--269, 1999. Preliminary version appeared in proceedings of Principles of Programming Languages, 1998. Revised version is Rice University technical report TR 97-293, June 1999.]] Google ScholarGoogle ScholarDigital LibraryDigital Library
  11. Gomes, B., D. Stoutamire, B. Vaysman and H. Klawitter. A Language Manual for Sather 1.1, August 1996.]]Google ScholarGoogle Scholar
  12. Gosling, J., B. Joy and J. Guy~Steele. The Java(tm) Language Specification. Addison-Wesley, 1996.]] Google ScholarGoogle ScholarDigital LibraryDigital Library
  13. Harper, R. and M. Lillibridge. A type-theoretic approach to higher-order modules with sharing. In Proceedings of ACM Conference Principles of Programming Languages, pages 123--137, Janurary 1994.]] Google ScholarGoogle ScholarDigital LibraryDigital Library
  14. Holt, R. C. and J. R. Cordy. The Turing programming language. In Communications of the ACM, volume 31, pages 1310--1423, December 1988.]] Google ScholarGoogle ScholarDigital LibraryDigital Library
  15. Jones, M. P., A. Reid and The Yale Haskell Group. The Hugs 98 User Manual, 1999.]]Google ScholarGoogle Scholar
  16. Kelsey, R., W. Clinger and J. R. (Editors). Revised5 report of the algorithmic language Scheme. ACM SIGPLAN Notices, 33(9):26--76, 1998.]] Google ScholarGoogle ScholarDigital LibraryDigital Library
  17. Kölling, M. and J. Rosenberg. Blue: Language Specification, version 0.94, 1997.]]Google ScholarGoogle Scholar
  18. Leroy, X. Manifest types, modules, and separate compilation. In Proceedings of ACM Conference Principles of Programming Languages, pages 109--122, Janurary 1994.]] Google ScholarGoogle ScholarDigital LibraryDigital Library
  19. Leroy, X. The Objective Caml system, Documentation and User's guide, 1997.]]Google ScholarGoogle Scholar
  20. Luckham, D. Programming with specifications. Texts and Monographs in Computer Science, 1990.]] Google ScholarGoogle ScholarDigital LibraryDigital Library
  21. Luckham, D. C. and F. von Henke. An overview of Anna, a specification language for Ada. In IEEE Software, volume 2, pages 9--23, March 1985.]]Google ScholarGoogle ScholarDigital LibraryDigital Library
  22. Meyer, B. Eiffel: The Language. Prentice Hall, 1992.]] Google ScholarGoogle ScholarDigital LibraryDigital Library
  23. Milner, R., M. Tofte and R. Harper. The Definition of Standard ML. MIT Press, 1990.]] Google ScholarGoogle ScholarDigital LibraryDigital Library
  24. Mitchell, J. C. and G. D. Plotkin. Abstract types have existential type. ACM Transactions on Programming Languages and Systems, 10(3):470--502, 1988.]] Google ScholarGoogle ScholarDigital LibraryDigital Library
  25. Parnas, D. L. A technique for software module specification with examples. Communications of the ACM, 15(5):330--336, May 1972.]] Google ScholarGoogle ScholarDigital LibraryDigital Library
  26. Rémy, D. and J. Vouillon. Objective ML: A simple object-oriented extension of ML. In Proceedings of ACM Conference Principles of Programming Languages, pages 40--53, January 1997.]] Google ScholarGoogle ScholarDigital LibraryDigital Library
  27. Rosenblum, D. S. A practical approach to programming with assertions. IEEE Transactions on Software Engineering, 21(1):19--31, Janurary 1995.]] Google ScholarGoogle ScholarDigital LibraryDigital Library
  28. Serrano, M. Bigloo: A practical Scheme compiler, 1992--2002.]]Google ScholarGoogle Scholar
  29. Serrano, M. Bee: an integrated development environment for the Scheme programming language. Journal of Functional Programming, 10(2):1--43, May 2000.]] Google ScholarGoogle ScholarDigital LibraryDigital Library
  30. Steele, G. L. J. Debunking the "expensive procedure call" myth; or, Procedure call implementations considered harmful; or, LAMBDA: The ultimate goto. Technical Report 443, MIT Artificial Intelligence Laboratory, 1977. First appeared in the Proceedings of the ACM National Conference (Seattle, October 1977), 153--162.]] Google ScholarGoogle ScholarDigital LibraryDigital Library
  31. Switzer, R. Eiffel: An Introduction. Prentice Hall, 1993.]] Google ScholarGoogle ScholarDigital LibraryDigital Library
  32. Szyperski, C. Component Software. Addison-Wesley, 1998.]]Google ScholarGoogle Scholar
  33. The GHC Team. The Glasgow Haskell Compiler User's Guide, 1999.]]Google ScholarGoogle Scholar
  34. Wright, A. and M. Felleisen. A syntactic approach to type soundness. Information and Computation, pages 38--94, 1994. First appeared as Technical Report TR160, Rice University, 1991.]] Google ScholarGoogle ScholarDigital LibraryDigital Library

Index Terms

  1. Contracts for higher-order functions

      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
      • Published in

        cover image ACM Conferences
        ICFP '02: Proceedings of the seventh ACM SIGPLAN international conference on Functional programming
        October 2002
        294 pages
        ISBN:1581134878
        DOI:10.1145/581478
        • cover image ACM SIGPLAN Notices
          ACM SIGPLAN Notices  Volume 37, Issue 9
          September 2002
          283 pages
          ISSN:0362-1340
          EISSN:1558-1160
          DOI:10.1145/583852
          Issue’s Table of Contents

        Copyright © 2002 ACM

        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]

        Publisher

        Association for Computing Machinery

        New York, NY, United States

        Publication History

        • Published: 17 September 2002

        Permissions

        Request permissions about this article.

        Request Permissions

        Check for updates

        Qualifiers

        • Article

        Acceptance Rates

        ICFP '02 Paper Acceptance Rate24of76submissions,32%Overall Acceptance Rate333of1,064submissions,31%

        Upcoming Conference

        ICFP '24

      PDF Format

      View or Download as a PDF file.

      PDF

      eReader

      View online with eReader.

      eReader