Typed contracts for functional programming

  • Authors:
  • Ralf Hinze;Johan Jeuring;Andres Löh

  • Affiliations:
  • Institut für Informatik III, Universität Bonn, Bonn, Germany;Institute of Information and Computing Sciences, Utrecht University, Utrecht, The Netherlands;Institut für Informatik III, Universität Bonn, Bonn, Germany

  • Venue:
  • FLOPS'06 Proceedings of the 8th international conference on Functional and Logic Programming
  • Year:
  • 2006

Quantified Score

Hi-index 0.00

Visualization

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.