skip to main content
research-article

A theory of typed coercions and its applications

Published: 31 August 2009 Publication History

Abstract

A number of important program rewriting scenarios can be recast as type-directed coercion insertion. These range from more theoretical applications such as coercive subtyping and supporting overloading in type theories, to more practical applications such as integrating static and dynamically typed code using gradual typing, and inlining code to enforce security policies such as access control and provenance tracking. In this paper we give a general theory of type-directed coercion insertion. We specifically explore the inherent tradeoff between expressiveness and ambiguity--the more powerful the strategy for generating coercions, the greater the possibility of several, semantically distinct rewritings for a given program. We consider increasingly powerful coercion generation strategies, work out example applications supported by the increased power (including those mentioned above), and identify the inherent ambiguity problems of each setting, along with various techniques to tame the ambiguities.

Supplementary Material

JPG File (atheoryoftypedcoercionsanditsapplicationsonvimeo.jpg)
MP4 File (atheoryoftypedcoercionsanditsapplicationsonvimeo.mp4)

References

[1]
P. Aczel. A notion of class for type theory, 1995. Unpublished manuscript.
[2]
G. Barthe. Implicit coercions in type theories. In Proc. of Types workshop, 1996.
[3]
V. Breazu-Tannen, T. Coquand, C. Gunter, and A. Scedrov. Inheritance as implicit coercion. Information and Computation, 93: 172--221, 1991.
[4]
J. Cheney, A. Ahmed, and U. A. Acar. Provenance as dependency analysis. In Proc. of DBPL, 2007.
[5]
C. Flanagan. Hybrid type checking. In Proc. of POPL, 2006.
[6]
V. Ganapathy, T. Jaeger, and S. Jha. Retrofitting legacy code for authorization policy enforcement. Proc. of Security and Privacy, 2006.
[7]
F. Henglein. Dynamic typing: syntax and proof theory. Science of Computer Programming, 22: 197--230, 1994.
[8]
S. Lindley, P. Wadler, and J. Yallop. Idioms are oblivious, arrows are meticulous, monads are promiscuous. In Proc. of MSFP, 2008.
[9]
Z. Luo. Coercions in a polymorphic type system. Mathematical Structures in Computer Science, 18 (4): 729--751, 2008.
[10]
Z. Luo. Coercive subtyping in type theory. In Proc. of CSL, 1996.
[11]
Z. Luo. Coercive subtyping. Journal of Logic and Computation, 9 (1): 105--130, 1999.
[12]
Z. Luo and R. Kießling. Coercions in Hindley-Milner systems. In Proc. of Types, 2004.
[13]
Z. Luo and Y. Luo. Transitivity in coercive subtyping. Information and Computation, 197 (1-2): 122--144, 2005.
[14]
P. Pratikakis, J. Spacco, and M. Hicks. Transparent proxies for Java futures. In Proc. of OOPSLA, 2004.
[15]
A. Sabelfeld and A. C. Myers. Language--based information-flow security. JSAC, 21 (1): 5--19, 2003.
[16]
A. Saıbi. Typing algorithm in type theory with inheritance. In Proc. of POPL, 1997.
[17]
J. G. Siek and W. Taha. Gradual typing for functional languages. In Proc. of Scheme and Functional Programming Workshop, 2006.
[18]
J. G. Siek, R. Garcia, and W. Taha. Exploring the design space of higher-order casts. In Proc. of ESOP, 2009.
[19]
G. Stoyle, M. Hicks, G. Bierman, P. Sewell, and I. Neamtiu. Mutatis Mutandis: Safe and flexible dynamic software updating. ACM TOPLAS, 29 (4), 2007.
[20]
M. Sulzmann, M. M. T. Chakravarty, S. Peyton Jones, and K. Donnelly. System F with type equality coercions. In Proc. of TLDI, 2007.
[21]
N. Swamy, B. J. Corcoran, and M. Hicks. Fable: A language for enforcing user-defined security policies. In Proc. of Security and Privacy, 2008.
[22]
N. Swamy, M. Hicks, and G. Bierman. A theory of typed coercions and its applications. Technical Report MSR-TR-2009-69, Microsoft Research, 2009.
[23]
P. Wadler and R. B. Findler. Well-typed programs can't be blamed. In Proc. of ESOP, 2009.

Recommendations

Reviews

William M. Waite

The report on ALGOL 68 [1] introduced the term "coercion" to describe an implicit change of mode. For example, if x is an ALGOL 68 integer variable, then it has mode "ref integer." In the expression x +1, however, the operator requires operands of mode integer. Rather than requiring the programmer to explicitly change the mode of x , the language definition implies a mode change on the basis of context. In effect, the compiler is allowed to insert an operation not specified by the programmer. For many situations, the concept of implicit operations inserted by a processor is useful. This paper provides a theory that covers a wide variety of such applications, and explores the tradeoff between expressiveness and ambiguity, which are inherent to these applications. Although the paper is clearly written and includes relevant examples to illustrate the concepts, readers must be familiar with lambda calculus and the notations used for grammars and type-checking rules. The theory is stated in terms of rewriting systems for the simply typed lambda calculus that is based on sets of coercion generation and coercion insertion rules. For each system, Swamy, Hicks, and Bierman indicate the conditions under which the rewriting will be unambiguous. Overload resolution provides a simple example that has both ambiguous and unambiguous solutions, with the ambiguous solution offering certain practical advantages. Although there is a general mechanism for solving the ambiguity in this case, it lies beyond the scope of the paper. Despite such limitations, thoughtful compiler writers will find much to mull over in this paper. Online Computing Reviews Service

Access critical reviews of Computing literature here

Become a reviewer for Computing Reviews.

Comments

Information & Contributors

Information

Published In

cover image ACM SIGPLAN Notices
ACM SIGPLAN Notices  Volume 44, Issue 9
ICFP '09
September 2009
343 pages
ISSN:0362-1340
EISSN:1558-1160
DOI:10.1145/1631687
Issue’s Table of Contents
  • cover image ACM Conferences
    ICFP '09: Proceedings of the 14th ACM SIGPLAN international conference on Functional programming
    August 2009
    364 pages
    ISBN:9781605583327
    DOI:10.1145/1596550
Permission to make digital or hard copies of all or part of this work for personal or classroom use is granted without fee provided that copies are not made or distributed for profit or commercial advantage and that copies bear this notice and the full citation on the first page. Copyrights for components of this work owned by others than ACM must be honored. Abstracting with credit is permitted. To copy otherwise, or republish, to post on servers or to redistribute to lists, requires prior specific permission and/or a fee. Request permissions from [email protected]

Publisher

Association for Computing Machinery

New York, NY, United States

Publication History

Published: 31 August 2009
Published in SIGPLAN Volume 44, Issue 9

Check for updates

Author Tags

  1. coercion insertion
  2. gradual typing
  3. nonambiguity
  4. provenance
  5. type-directed translation

Qualifiers

  • Research-article

Contributors

Other Metrics

Bibliometrics & Citations

Bibliometrics

Article Metrics

  • Downloads (Last 12 months)2
  • Downloads (Last 6 weeks)0
Reflects downloads up to 26 Jan 2025

Other Metrics

Citations

View Options

Login options

View options

PDF

View or Download as a PDF file.

PDF

eReader

View online with eReader.

eReader

Figures

Tables

Media

Share

Share

Share this Publication link

Share on social media