skip to main content
research-article

Practical typed lazy contracts

Published:09 September 2012Publication History
Skip Abstract Section

Abstract

Until now there has been no support for specifying and enforcing contracts within a lazy functional program. That is a shame, because contracts consist of pre- and post-conditions for functions that go beyond the standard static types. This paper presents the design and implementation of a small, easy-to-use, purely functional contract library for Haskell, which, when a contract is violated, also provides more useful information than the classical blaming of one contract partner. From now on lazy functional languages can profit from the assurances in the development of correct programs that contracts provide.

References

  1. M. Blume and D. McAllester. Sound and complete models of contracts. J. Funct. Program., 16 (4-5): 375--414, 2006. Google ScholarGoogle ScholarDigital LibraryDigital Library
  2. O. Chitil. A semantics for lazy assertions. In Proceedings of the 20th ACM SIGPLAN workshop on Partial evaluation and program manipulation, PEPM 2011, pages 141--150, January 2011. Google ScholarGoogle ScholarDigital LibraryDigital Library
  3. O. Chitil and F. Huch. Monadic, prompt lazy assertions in Haskell. In APLAS 2007, LNCS 4807, pages 38--53, 2007. Google ScholarGoogle ScholarDigital LibraryDigital Library
  4. O. Chitil and F. Huch. A pattern logic for prompt lazy assertions in Haskell. In Implementation and Application of Functional Languages: 18th International Workshop, IFL 2006, LNCS 4449, 2007. Google ScholarGoogle ScholarDigital LibraryDigital Library
  5. O. Chitil, D. McNeill, and C. Runciman. Lazy assertions. In Implementation of Functional Languages: 15th International Workshop, IFL 2003, LNCS 3145, pages 1--19. Springer, November 2004. Google ScholarGoogle ScholarDigital LibraryDigital Library
  6. N. A. Danielsson and P. Jansson. Chasing bottoms, a case study in program verification in the presence of partial and infinite values. In D. Kozen, editor, Proceedings of the 7th International Conference on Mathematics of Program Construction, MPC 2004, LNCS 3125, pages 85--109. Springer-Verlag, July 2004.Google ScholarGoogle Scholar
  7. M. Degen, P. Thiemann, and S. Wehr. True lies: Lazy contracts for lazy languages (faithfulness is better than laziness). In 4. Arbeitstagung Programmiersprachen (ATPS'09), Lübeck, Germany, October 2009.Google ScholarGoogle Scholar
  8. M. Degen, P. Thiemann, and S. Wehr. The interaction of contracts and laziness. In Proceedings of the ACM SIGPLAN 2012 workshop on Partial evaluation and program manipulation, PEPM '12, pages 97--106, 2012. Google ScholarGoogle ScholarDigital LibraryDigital Library
  9. C. Dimoulas, R. B. Findler, C. Flanagan, and M. Felleisen. Correct blame for contracts: no more scapegoating. In Proceedings of the 38th annual ACM SIGPLAN-SIGACT symposium on Principles of programming languages, POPL '11, pages 215--226, 2011. Google ScholarGoogle ScholarDigital LibraryDigital Library
  10. R. B. Findler. Comparison with Racket's contract system. Personal communication, 2012.Google ScholarGoogle Scholar
  11. R. B. Findler and M. Blume. Contracts as pairs of projections. In International Symposium on Functional and Logic Programming (FLOPS), LNCS 3945, pages 226--241, 2006. Google ScholarGoogle ScholarDigital LibraryDigital Library
  12. R. B. Findler and M. Felleisen. Contracts for higher-order functions. In ICFP '02: Proceedings of the seventh ACM SIGPLAN international conference on Functional programming, pages 48--59, 2002. Google ScholarGoogle ScholarDigital LibraryDigital Library
  13. R. B. Findler, M. Blume, and M. Felleisen. An investigation of contracts as projections. Technical report, University of Chicago Computer Science Department, 2004. TR-2004-02.Google ScholarGoogle Scholar
  14. M. Flatt and PLT. Reference: Racket. Technical Report PLT-TR-2010-1, PLT Inc., 2010. http://docs.racket-lang.org/trl/.Google ScholarGoogle Scholar
  15. M. Flatt, R. B. Findler, and PLT. The Racket guide. http://docs.racket-lang.org/guide/index.html, 2012.Google ScholarGoogle Scholar
  16. A. Gill. Debugging Haskell by observing intermediate datastructures. Electronic Notes in Theoretical Computer Science, 41 (1), 2001. (Proc. 2000 ACM SIGPLAN Haskell Workshop).Google ScholarGoogle Scholar
  17. R. Hinze. Generics for the masses. J. Funct. Program., 16 (4-5): 451--483, July 2006. Google ScholarGoogle ScholarDigital LibraryDigital Library
  18. R. Hinze and A. Löh. Generic programming in 3d. Sci. Comput. Program., 74 (8): 590--628, June 2009. Google ScholarGoogle ScholarDigital LibraryDigital Library
  19. R. Hinze, J. Jeuring, and A. Löh. Typed contracts for functional programming. In Proceedings of the 8th International Symposium on Functional and Logic Programming, FLOPS 2006, LNCS 3945, pages 208--225, 2006. Google ScholarGoogle ScholarDigital LibraryDigital Library
  20. R. Lämmel and S. P. Jones. Scrap your boilerplate: a practical design pattern for generic programming. In Proceedings of the 2003 ACM SIGPLAN international workshop on Types in languages design and implementation, TLDI '03, pages 26--37, 2003. Google ScholarGoogle ScholarDigital LibraryDigital Library
  21. R. Lämmel and S. P. Jones. Scrap more boilerplate: reflection, zips, and generalised casts. In Proceedings of the ninth ACM SIGPLAN international conference on Functional programming, ICFP '04, pages 244--255, 2004. Google ScholarGoogle ScholarDigital LibraryDigital Library
  22. S. Peyton Jones, A. Reid, T. Hoare, S. Marlow, and F. Henderson. A semantics for imprecise exceptions. In Proceedings of the ACM SIGPLAN '99 Conference on Programming Language Design and Implementation, pages 25--36, 1999. Google ScholarGoogle ScholarDigital LibraryDigital Library
  23. T. Sheard and S. P. Jones. Template meta-programming for Haskell. In Proceedings of the 2002 ACM SIGPLAN workshop on Haskell, Haskell '02, pages 1--16, 2002. Google ScholarGoogle ScholarDigital LibraryDigital Library

Index Terms

  1. Practical typed lazy contracts

    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

    • Published in

      cover image ACM SIGPLAN Notices
      ACM SIGPLAN Notices  Volume 47, Issue 9
      ICFP '12
      September 2012
      368 pages
      ISSN:0362-1340
      EISSN:1558-1160
      DOI:10.1145/2398856
      Issue’s Table of Contents
      • cover image ACM Conferences
        ICFP '12: Proceedings of the 17th ACM SIGPLAN international conference on Functional programming
        September 2012
        392 pages
        ISBN:9781450310543
        DOI:10.1145/2364527

      Copyright © 2012 ACM

      Publisher

      Association for Computing Machinery

      New York, NY, United States

      Publication History

      • Published: 9 September 2012

      Check for updates

      Qualifiers

      • research-article

    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!