Book contents
- Frontmatter
- Contents
- Preface
- Part I Judgments and Rules
- Part II Statics and Dynamics
- Part III Function Types
- Part IV Finite Data Types
- Part V Infinite Data Types
- Part VI Dynamic Types
- Part VII Variable Types
- Part VIII Subtyping
- Part IX Classes and Methods
- Part X Exceptions and Continuations
- Part XI Types and Propositions
- Part XII Symbols
- Part XIII State
- Part XIV Laziness
- Part XV Parallelism
- Part XVI Concurrency
- Part XVII Modularity
- Part XVIII Equational Reasoning
- 47 Equational Reasoning for T
- 48 Equational Reasoning for PCF
- 49 Parametricity
- 50 Process Equivalence
- Part XIX Appendix
- Bibliography
- Index
49 - Parametricity
from Part XVIII - Equational Reasoning
Published online by Cambridge University Press: 05 February 2013
- Frontmatter
- Contents
- Preface
- Part I Judgments and Rules
- Part II Statics and Dynamics
- Part III Function Types
- Part IV Finite Data Types
- Part V Infinite Data Types
- Part VI Dynamic Types
- Part VII Variable Types
- Part VIII Subtyping
- Part IX Classes and Methods
- Part X Exceptions and Continuations
- Part XI Types and Propositions
- Part XII Symbols
- Part XIII State
- Part XIV Laziness
- Part XV Parallelism
- Part XVI Concurrency
- Part XVII Modularity
- Part XVIII Equational Reasoning
- 47 Equational Reasoning for T
- 48 Equational Reasoning for PCF
- 49 Parametricity
- 50 Process Equivalence
- Part XIX Appendix
- Bibliography
- Index
Summary
Themotivation for introducing polymorphism was to enablemore programs to be written—those that are “generic” Chapter 20. Then if a program does not depend on the choice of types, we can code it by using polymorphism. Moreover, if we wish to insist that a program cannot depend on a choice of types, we demand that it be polymorphic. Thus polymorphism can be used both to expand the collection of programs we may write and also to limit the collection of programs that are permissible in a given context.
The restrictions imposed by polymorphic typing give rise to the experience that in a polymorphic functional language, if the types are correct, then the program is correct. Roughly speaking, if a function has a polymorphic type, then the strictures of type genericity vastly cut down the set of programs with that type. Thus if you have written a program with this type, it is quite likely to be the one you intended!
The technical foundation for these remarks is called parametricity. The goal of this chapter is to give an account of parametricity for ℒ{→ ∀} under a call-by-name interpretation.
Overview
We begin with an informal discussion of parametricity based on a “seat of the pants” understanding of the set of well-formed programs of a type.
Suppose that a function value f has the type ∀(t .t → t).
- Type
- Chapter
- Information
- Practical Foundations for Programming Languages , pp. 433 - 445Publisher: Cambridge University PressPrint publication year: 2012