skip to main content
research-article

A theory of typed coercions and its applications

Published:31 August 2009Publication History
Skip Abstract Section

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.

Skip Supplemental Material Section

Supplemental Material

atheoryoftypedcoercionsanditsapplicationsonvimeo.mp4

References

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

Index Terms

  1. A theory of typed coercions and its applications

        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

        Login options

        Check if you have access through your login credentials or your institution to get full access on this article.

        Sign in

        Full Access

        • 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

          Copyright © 2009 ACM

          Publisher

          Association for Computing Machinery

          New York, NY, United States

          Publication History

          • Published: 31 August 2009

          Check for updates

          Qualifiers

          • research-article

        PDF Format

        View or Download as a PDF file.

        PDF

        eReader

        View online with eReader.

        eReader
        About Cookies On This Site

        We use cookies to ensure that we give you the best experience on our website.

        Learn more

        Got it!