Relationally-parametric polymorphic contracts

The analogy between types and contracts raises the question of how many features of static type systems can be expressed as dynamic contracts. An important feature missing in prior work on contracts is parametricity, as represented by the polymorphic types in languages like Standard ML. We present a contract counterpart to parametricity. We explore multiple designs for such a system and present one that is simple and incurs minimal execution overhead. We show how to extend the notion of contract blame to our definition. We present a form of inference that can often save programmers from having to explicitly instantiate many parametric contracts. Finally, we present several examples that illustrate how this system mimics the feel and properties of parametric polymorphism in typed languages.

[1]  John C. Mitchell,et al.  Abstract types have existential type , 1988, TOPL.

[2]  John L. Bruno,et al.  jContractor: A Reflective Java Library to Support Design by Contract , 1999, Reflection.

[3]  David S. Rosenblum A Practical Approach to Programming With Assertions , 1995, IEEE Trans. Software Eng..

[4]  Paul Hudak,et al.  Functional reactive animation , 1997, ICFP '97.

[5]  Robin Milner,et al.  Definition of standard ML , 1990 .

[6]  Matthew Flatt Composable and compilable macros:: you want it when? , 2002, ICFP '02.

[7]  Bertrand Meyer,et al.  Eiffel: The Language , 1991 .

[8]  Joyce L. Vedral,et al.  Functional Programming Languages and Computer Architecture , 1989, Lecture Notes in Computer Science.

[9]  Reinhold Plösch Design by Contract for Python , 1997, APSEC.

[10]  John C. Reynolds,et al.  Types, Abstraction and Parametric Polymorphism , 1983, IFIP Congress.

[11]  Robert Harper,et al.  Compiling polymorphism using intensional type analysis , 1995, POPL '95.

[12]  Dan Grossman,et al.  Principals in programming languages: a syntactic proof technique , 1999, ICFP '99.

[13]  Robin Milner,et al.  A Theory of Type Polymorphism in Programming , 1978, J. Comput. Syst. Sci..

[14]  Reinhold Plösch,et al.  Contracts: from analysis to C++ implementation , 1999, Proceedings of Technology of Object-Oriented Languages and Systems - TOOLS 30 (Cat. No.PR00278).

[15]  Matthias Felleisen,et al.  Contracts for higher-order functions , 2002, ICFP '02.

[16]  Robert Bruce Findler,et al.  Operational semantics for multi-language programs , 2007, POPL '07.

[17]  Ralf Hinze,et al.  Typed Contracts for Functional Programming , 2006, FLOPS.

[18]  Robert Bruce Findler,et al.  Contracts as Pairs of Projections , 2006, FLOPS.

[19]  Sam Tobin-Hochstadt,et al.  Interlanguage migration: from scripts to programs , 2006, OOPSLA '06.

[20]  Philip Wadler,et al.  Theorems for free! , 1989, FPCA.

[21]  Ernesto Pimentel,et al.  Design by Contract in Smalltalk , 1996, J. Object Oriented Program..

[22]  Benjamin C. Pierce,et al.  Relating Cryptography and Polymorphism , 2000 .

[23]  Shriram Krishnamurthi,et al.  Crossing State Lines: Adapting Object-Oriented Frameworks to Functional Reactive Languages , 2006, FLOPS.

[24]  Matthias Felleisen,et al.  Behavioral contracts and behavioral subtyping , 2001, ESEC/FSE-9.