Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to main content

Typed Contracts for Functional Programming

  • Conference paper
Functional and Logic Programming (FLOPS 2006)

Part of the book series: Lecture Notes in Computer Science ((LNPSE,volume 3945))

Included in the following conference series:

Abstract

A robust software component fulfills a contract: it expects data satisfying a certain property and promises to return data satisfying another property. The object-oriented community uses the design-by-contract approach extensively. Proposals for language extensions that add contracts to higher-order functional programming have appeared recently. In this paper we propose an embedded domain-specific language for typed, higher-order and first-class contracts, which is both more expressive than previous proposals, and allows for a more informative blame assignment. We take some first steps towards an algebra of contracts, and we show how to define a generic contract combinator for arbitrary algebraic data types. The contract language is implemented as a library in Haskell using the concept of generalised algebraic data types.

This is a preview of subscription content, log in via an institution to check access.

Access this chapter

Subscribe and save

Springer+ Basic
$34.99 /Month
  • Get 10 units per month
  • Download Article/Chapter or eBook
  • 1 Unit = 1 Article or 1 Chapter
  • Cancel anytime
Subscribe now

Buy Now

Chapter
USD 29.95
Price excludes VAT (USA)
  • Available as PDF
  • Read on any device
  • Instant download
  • Own it forever
eBook
USD 39.99
Price excludes VAT (USA)
  • Available as PDF
  • Read on any device
  • Instant download
  • Own it forever
Softcover Book
USD 54.99
Price excludes VAT (USA)
  • Compact, lightweight edition
  • Dispatched in 3 to 5 business days
  • Free shipping worldwide - see info

Tax calculation will be finalised at checkout

Purchases are for personal use only

Institutional subscriptions

Preview

Unable to display preview. Download preview PDF.

Unable to display preview. Download preview PDF.

Similar content being viewed by others

References

  1. Meyer, B.: Applying ‘design by contract’. IEEE Computer 25(10), 40–51 (1992)

    Article  Google Scholar 

  2. Meyer, B.: Eiffel: The Language. Prentice Hall, Englewood Cliffs (1992)

    MATH  Google Scholar 

  3. Findler, R.B., Felleisen, M.: Contracts for higher-order functions. ACM SIGPLAN Notices 37(9), 48–59 (2002)

    Article  MATH  Google Scholar 

  4. Peyton Jones, S.: Haskell 98 Language and Libraries. Cambridge University Press, Cambridge (2003)

    MATH  Google Scholar 

  5. The GHC Team: The Glorious Glasgow Haskell Compilation System User’s Guide, Version 6.4.1 (2005), http://www.haskell.org/ghc/

  6. Blume, M., McAllester, D.: A sound (and complete) model of contracts. ACM SIGPLAN Notices 39(9), 189–200 (2004)

    Article  MATH  Google Scholar 

  7. Xi, H., Chen, C., Chen, G.: Guarded recursive datatype constructors. In: POPL 2003, pp. 224–235. ACM Press, New York (2003)

    Google Scholar 

  8. Hinze, R.: Fun with phantom types. In: Gibbons, J., de Moor, O. (eds.) The Fun of Programming, pp. 245–262. Palgrave Macmillan, Basingstoke (2003); ISBN 1-4039-0772-2 hardback, ISBN 0-333-99285-7 paperback

    Chapter  Google Scholar 

  9. Peyton Jones, S., Washburn, G., Weirich, S.: Wobbly types: Type inference for generalised algebraic data types. Technical Report MS-CIS-05-26, University of Pennsylvania (2005)

    Google Scholar 

  10. Hinze, R.: Polytypic values possess polykinded types. Science of Computer Programming 43, 129–159 (2002)

    Article  MathSciNet  MATH  Google Scholar 

  11. Hutton, G.: A tutorial on the universality and expressiveness of fold. Journal of Functional Programming 9(4), 355–372 (1999)

    Article  MATH  Google Scholar 

  12. Wadler, P.: Theorems for free! In: The Fourth International Conference on Functional Programming Languages and Computer Architecture (FPCA 1989), London, UK, pp. 347–359. Addison-Wesley Publishing Company, Reading (1989)

    Chapter  Google Scholar 

  13. Findler, R.B.: Behavioral software contracts (dissertation). Technical Report TR02-402, Department of Computer Science, Rice University (2002)

    Google Scholar 

  14. Blume, M., McAllester, D.: Sound and complete models of contracts. Journal of Functional Programming (2006) (to appear)

    Google Scholar 

  15. Findler, R.B., Blume, M., Felleisen, M.: An investigation of contracts as projections. Technical Report TR-2004-02, The University of Chicago (2004)

    Google Scholar 

  16. Nordström, B., Petersson, K., Smith, J.: Programming in Martin-Löf’s Type Theory. Oxford University Press, Oxford (1990)

    MATH  Google Scholar 

  17. Claessen, K., Runciman, C., Chitil, O., Hughes, J., Wallace, M.: Testing and tracing lazy functional programs using Quickcheck and Hat. In: Jeuring, J., Peyton Jones, S. (eds.) AFP 2002. LNCS, vol. 2638. Springer, Heidelberg (2003)

    Chapter  Google Scholar 

  18. Chitil, O., McNeill, D., Runciman, C.: Lazy assertions. In: Trinder, P., Michaelson, G.J., Peña, R. (eds.) IFL 2003. LNCS, vol. 3145, pp. 1–19. Springer, Heidelberg (2004)

    Chapter  Google Scholar 

Download references

Author information

Authors and Affiliations

Authors

Editor information

Editors and Affiliations

Rights and permissions

Reprints and permissions

Copyright information

© 2006 Springer-Verlag Berlin Heidelberg

About this paper

Cite this paper

Hinze, R., Jeuring, J., Löh, A. (2006). Typed Contracts for Functional Programming. In: Hagiya, M., Wadler, P. (eds) Functional and Logic Programming. FLOPS 2006. Lecture Notes in Computer Science, vol 3945. Springer, Berlin, Heidelberg. https://doi.org/10.1007/11737414_15

Download citation

  • DOI: https://doi.org/10.1007/11737414_15

  • Publisher Name: Springer, Berlin, Heidelberg

  • Print ISBN: 978-3-540-33438-5

  • Online ISBN: 978-3-540-33439-2

  • eBook Packages: Computer ScienceComputer Science (R0)

Publish with us

Policies and ethics