Contracts for Higher-Order Functions

被引:0
|
作者
Findler, Robert Bruce [1 ]
Felleisen, Matthias [1 ]
机构
[1] Northeastern Univ, Coll Comp Sci, Boston, MA 02115 USA
关键词
Design; Languages; Reliability; Contracts; Higher-order Functions; Behavioral Specifications; Predicate Typing; Software Reliability; SPECIFICATION; LANGUAGE; SCHEME;
D O I
10.1145/2502508.2502521
中图分类号
TP31 [计算机软件];
学科分类号
081202 ; 0835 ;
摘要
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 lambda(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.
引用
收藏
页码:34 / 45
页数:12
相关论文
共 50 条
  • [1] Contracts for higher-order functions
    Findler, RB
    Felleisen, M
    [J]. ACM SIGPLAN NOTICES, 2002, 37 (09) : 48 - 59
  • [2] Temporal Higher-Order Contracts
    Disney, Tim
    Flanagan, Cormac
    McCarthy, Jay
    [J]. ACM SIGPLAN NOTICES, 2011, 46 (09) : 176 - 188
  • [3] Temporal Higher-Order Contracts
    Disney, Tim
    Flanagan, Cormac
    McCarthy, Jay
    [J]. ICFP 11 - PROCEEDINGS OF THE 2011 ACM SIGPLAN: INTERNATIONAL CONFERENCE ON FUNCTIONAL PROGRAMMING, 2011, : 176 - 188
  • [4] Higher-Order Symbolic Execution via Contracts
    Tobin-Hochstadt, Sam
    Van Horn, David
    [J]. ACM SIGPLAN NOTICES, 2012, 47 (10) : 537 - 554
  • [5] HIGHER-ORDER COHERENCE FUNCTIONS
    NATH, R
    [J]. LETTERE AL NUOVO CIMENTO, 1978, 23 (13): : 494 - 496
  • [6] Blame Assignment for Higher-Order Contracts with Intersection and Union
    Keil, Matthias
    Thiemann, Peter
    [J]. PROCEEDINGS OF THE 20TH ACM SIGPLAN INTERNATIONAL CONFERENCE ON FUNCTIONAL PROGRAMMING (ICFP'15), 2015, : 375 - 386
  • [7] USING HIGHER-ORDER CONTRACTS TO MODEL SESSION TYPES
    Bernardi, Giovanni
    Hennessy, Matthew
    [J]. LOGICAL METHODS IN COMPUTER SCIENCE, 2016, 12 (02)
  • [8] Blame Assignment for Higher-Order Contracts with Intersection and Union
    Keil, Matthias
    Thiemann, Peter
    [J]. ACM SIGPLAN NOTICES, 2015, 50 (09) : 375 - 386
  • [9] STRICTNESS ANALYSIS FOR HIGHER-ORDER FUNCTIONS
    BURN, GL
    HANKIN, C
    ABRAMSKY, S
    [J]. SCIENCE OF COMPUTER PROGRAMMING, 1986, 7 (03) : 249 - 278
  • [10] The higher-order derivatives of spectral functions
    Sendov, Hristo S.
    [J]. LINEAR ALGEBRA AND ITS APPLICATIONS, 2007, 424 (01) : 240 - 281