Typed Contracts for Functional Programming
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.
Unable to display preview. Download preview PDF.
- 5.The GHC Team: The Glorious Glasgow Haskell Compilation System User’s Guide, Version 6.4.1 (2005), http://www.haskell.org/ghc/
- 7.Xi, H., Chen, C., Chen, G.: Guarded recursive datatype constructors. In: POPL 2003, pp. 224–235. ACM Press, New York (2003)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
- 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