skip to main content
research-article
Open Access

Hybrid type checking

Published:08 February 2010Publication History
Skip Abstract Section

Abstract

Traditional static type systems are effective for verifying basic interface specifications. Dynamically checked contracts support more precise specifications, but these are not checked until runtime, resulting in incomplete detection of defects. Hybrid type checking is a synthesis of these two approaches that enforces precise interface specifications, via static analysis where possible, but also via dynamic checks where necessary. This article explores the key ideas and implications of hybrid type checking, in the context of the λ-calculus extended with contract types, that is, with dependent function types and with arbitrary refinements of base types.

References

  1. Parnas, D. L. 1972. A technique for software module specification with examples. Comm. ACM 15, 5, 330--336. Google ScholarGoogle ScholarDigital LibraryDigital Library
  2. Abadi, M., Cardelli, L., Pierce, B., and Plotkin, G. 1989. Dynamic typing in a statically-typed language. In Proceedings of the Symposium on Principles of Programming Languages. 213--227. Google ScholarGoogle ScholarDigital LibraryDigital Library
  3. Agarwal, R. and Stoller, S. D. 2004. Type inference for parameterized race-free Java. In Proceedings of the Conference on Verification, Model Checking, and Abstract Interpretation. 149--160.Google ScholarGoogle Scholar
  4. Aiken, A., Wimmers, E. L., and Lakshman, T. K. 1994. Soft typing with conditional types. In Proceedings of the Symposium on Principles of Programming Languages. 163--173. Google ScholarGoogle ScholarDigital LibraryDigital Library
  5. Augustsson, L. 1998. Cayenne — A language with dependent types. In Proceedings of the ACM International Conference on Functional Programming. 239--250. Google ScholarGoogle ScholarDigital LibraryDigital Library
  6. Blei, D., Harrelson, C., Jhala, R., Majumdar, R., Necula, G. C., Rahul, S. P., Weimer, W., and Weitz, D. 2000. Vampyre. http://www-cad.eecs.berkeley.edu/~rupak/Vampyre/.Google ScholarGoogle Scholar
  7. Blume, M. and McAllester, D. 2006. Sound and complete models for contracts. J. Funct. Program.16, 375--414. Google ScholarGoogle ScholarDigital LibraryDigital Library
  8. Breazu-Tannen, V., Coquand, T., Gunter, C. A., and Scedrov, A. 1991. Inheritance as implicit coercion. Inform. Comput. 93, 1, 172--221. Google ScholarGoogle ScholarDigital LibraryDigital Library
  9. Burdy, L., Cheon, Y., Cok, D., Ernst, M., Kiniry, J., Leavens, G., Leino, K., and Poll, E. 2003. An overview of JML tools and applications. In 8th International Workshop on Formal Methods for Industrial Critical Systems (FMICS '03). Electronic Notes in Theoretical Computer Science, T. Arts and W. Fokkink, Eds., vol. 80. Elsevier. 73--89.Google ScholarGoogle Scholar
  10. Cardelli, L. 1988a. Phase distinctions in type theory. Manuscript. http://lucacardelli.name/Papers/PhaseDistinctions.pdf.Google ScholarGoogle Scholar
  11. Cardelli, L. 1988b. Typechecking dependent types and subtypes. In Foundations of Logic and Functional Programming. Lecture Notes in Computer Science. Springer, 45--57.Google ScholarGoogle ScholarDigital LibraryDigital Library
  12. Davies, R. and Pfenning, F. 2000. Intersection types and computational effects. In Proceedings of the International Conference on Functional Programming. 198--208. Google ScholarGoogle ScholarDigital LibraryDigital Library
  13. Denney, E. 1998. Refinement types for specification. In Proceedings of the IFIP International Conference on Programming Concepts and Methods. Vol. 125. Chapman and Hall, 148--166. Google ScholarGoogle ScholarDigital LibraryDigital Library
  14. Detlefs, D., Nelson, G., and Saxe, J. B. 2005. Simplify: A theorem prover for program checking. J. ACM 52, 3, 365--473. Google ScholarGoogle ScholarDigital LibraryDigital Library
  15. Fagan, M. 1990. Soft typing. Ph.D. thesis, Rice University.Google ScholarGoogle Scholar
  16. Findler, R. B. 2002. Behavioral software contracts. Ph.D. thesis, Rice University. Google ScholarGoogle ScholarDigital LibraryDigital Library
  17. Findler, R. B. and Felleisen, M. 2002. Contracts for higher-order functions. In Proceedings of the International Conference on Functional Programming. 48--59. Google ScholarGoogle ScholarDigital LibraryDigital Library
  18. Flanagan, C. 2006. Hybrid type checking. In Proceedings of the Symposium on Principles of Programming Languages. 245--256. Google ScholarGoogle ScholarDigital LibraryDigital Library
  19. Flanagan, C., Flatt, M., Krishnamurthi, S., Weirich, S., and Felleisen, M. 1996. Finding bugs in the web of program invariants. In Proceedings of the Conference on Programming Language Design and Implementation. 23--32. Google ScholarGoogle ScholarDigital LibraryDigital Library
  20. Flanagan, C., Leino, K. R. M., Lillibridge, M., Nelson, G., Saxe, J. B., and Stata, R. 2002. Extended static checking for Java. In Proceedings of the Conference on Programming Language Design and Implementation. 234--245. Google ScholarGoogle ScholarDigital LibraryDigital Library
  21. Freeman, T. and Pfenning, F. 1991. Refinement types for ML. In Proceedings of the Conference on Programming Language Design and Implementation. 268--277. Google ScholarGoogle ScholarDigital LibraryDigital Library
  22. Frisch, A., Castagna, G., and Benzaken, V. 2002. Semantic subtyping. In Logic in Computer Science. 137--146. Google ScholarGoogle ScholarDigital LibraryDigital Library
  23. Godefroid, P., Klarlund, N., and Sen, K. 2005. DART: Directed automated random testing. In Proceedings of the Conference on Programming Language Design and Implementation. Google ScholarGoogle ScholarDigital LibraryDigital Library
  24. Gomes, B., Stoutamire, D., Vaysman, B., and Klawitter, H. 1996. A language manual for Sather 1.1. http://www.icsi.berkeley.edu/~sather/Documentation/LanguageDescription/webmaker/index.html.Google ScholarGoogle Scholar
  25. Gosling, J., Joy, B., and Steele, G. 1996. The Java Language Specification. Addison-Wesley. Google ScholarGoogle ScholarDigital LibraryDigital Library
  26. Gronski, J. and Flanagan, C. 2007. Unifying hybrid types and contracts. In Trends in Functional Programming.Google ScholarGoogle Scholar
  27. Gronski, J., Knowles, K., Tomb, A., Freund, S. N., and Flanagan, C. 2006. Sage: Practical hybrid checking for expressive types and specifications. In Proceedings of the Workshop on Scheme and Functional Programming. 93--104.Google ScholarGoogle Scholar
  28. Haines, N., Kindred, D., Morrisett, J. G., Nettles, S., and Wing, J. M. 1994. Composing first-class transactions. ACM Trans. Program. Lang. Syst. 16, 6, 1719--1736. Google ScholarGoogle ScholarDigital LibraryDigital Library
  29. Henglein, F. 1994. Dynamic typing: Syntax and proof theory. Sci. Comput. Program. 22, 3, 197--230. Google ScholarGoogle ScholarDigital LibraryDigital Library
  30. Herman, D., Tomb, A., and Flanagan, C. 2007. Space-Efficient gradual typing. In Trends in Functional Programming. 404--419.Google ScholarGoogle Scholar
  31. Holt, R. C. and Cordy, J. R. 1988. The Turing programming language. Comm. ACM 31, 1310--1424. Google ScholarGoogle ScholarDigital LibraryDigital Library
  32. Knowles, K. and Flanagan, C. 2007. Type reconstruction for general refinement types. In Proceedings of the European Symposium on Programming. 505--519. Google ScholarGoogle ScholarDigital LibraryDigital Library
  33. Kölling, M. and Rosenberg, J. 1997. Blue: Language specification, version 0.94.Google ScholarGoogle Scholar
  34. Leavens, G. T. and Cheon, Y. 2005. Design by contract with JML. http://www.cs.iastate.edu/~leavens/JML/.Google ScholarGoogle Scholar
  35. Luckham, D. 1990. Programming with specifications. Texts and Monographs in Computer Science. Google ScholarGoogle ScholarDigital LibraryDigital Library
  36. Mandelbaum, Y., Walker, D., and Harper, R. 2003. An effective theory of type refinements. In Proceedings of the International Conference on Functional Programming. ACM Press, New York, 213--225. Google ScholarGoogle ScholarDigital LibraryDigital Library
  37. Meyer, B. 1988. Object-Oriented Software Construction. Prentice Hall. Google ScholarGoogle ScholarDigital LibraryDigital Library
  38. Morrisett, G., Walker, D., Crary, K., and Glew, N. 1999. From System F to typed assembly language. ACM Trans. Program. Lang. Syst. 21, 3, 527--568. Google ScholarGoogle ScholarDigital LibraryDigital Library
  39. Necula, G. C. 1997. Proof-Carrying code. In Symposium on Principles of Programming Languages. Google ScholarGoogle ScholarDigital LibraryDigital Library
  40. Necula, G. C., McPeak, S., and Weimer, W. 2002. CCured: Type-Safe retrofitting of legacy code. In Proceedings of the Symposium on Principles of Programming Languages. 128--139. Google ScholarGoogle ScholarDigital LibraryDigital Library
  41. O'Callahan, R. and Choi, J.-D. 2003. Hybrid dynamic data race detection. In Proceedings of the Symposium on Principles and Practice of Parallel Programming. 167--178. Google ScholarGoogle ScholarDigital LibraryDigital Library
  42. Ou, X., Tan, G., Mandelbaum, Y., and Walker, D. 2004. Dynamic typing with dependent types. In Proceedings of the IFIP International Conference on Theoretical Computer Science. 437--450.Google ScholarGoogle Scholar
  43. Rondon, P. M., Kawaguchi, M., and Jhala, R. 2008. Liquid types. In Proceeding of the Conference on Programming Language Design and Implementation. Google ScholarGoogle ScholarDigital LibraryDigital Library
  44. Siek, J. and Taha, W. 2007. Gradual typing for objects. In Proceedings of the European Conference on Object Oriented Programming. 2--27. Google ScholarGoogle ScholarDigital LibraryDigital Library
  45. Siek, J. G. and Taha, W. 2006. Gradual typing for functional languages. In Proceedings of the Workshop on Scheme and Functional Programming.Google ScholarGoogle Scholar
  46. Statman, R. 1985. Logical relations and the typed lambda-calculus. Inform. Control 65, 2-3, 85--97.Google ScholarGoogle ScholarCross RefCross Ref
  47. Tarditi, D., Morrisett, G., Cheng, P., Stone, C., Harper, R., and Lee, P. 1996. TIL: A type-directed optimizing compiler for ML. ACM SIGPLAN Not. 31, 5, 181--192. Google ScholarGoogle ScholarDigital LibraryDigital Library
  48. Thatte, S. 1990. Quasi-Static typing. In Proceedings of the Symposium on Principles of Programming Languages. 367--381. Google ScholarGoogle ScholarDigital LibraryDigital Library
  49. Vitek, J., Jagannathan, S., Welc, A., and Hosking, A. L. 2004. A semantic framework for designer transactions. In Proceedings of the European Symposium on Programming. 249--263.Google ScholarGoogle Scholar
  50. von Praun, C. and Gross, T. 2001. Object race detection. In Proceedings of the Conference on Object-Oriented Programming, Systems, Languages and Applications. 70--82. Google ScholarGoogle ScholarDigital LibraryDigital Library
  51. Wadler, P. and Findler, R. B. 2007. Well-Typed programs can't be blamed. In Proceedings of the Workshop on Scheme and Functional Programming.Google ScholarGoogle Scholar
  52. Wright, A. and Cartwright, R. 1994. A practical soft type system for scheme. In Proceedings of the Conference on Lisp and Functional Programming. 250--262. Google ScholarGoogle ScholarDigital LibraryDigital Library
  53. Wright, A. and Felleisen, M. 1994. A syntactic approach to type soundness. Inform. Comput. 115, 1, 38--94. Google ScholarGoogle ScholarDigital LibraryDigital Library
  54. Xi, H. 2000. Imperative programming with dependent types. In Proceedings of the Annual IEEE Symposium on Logic in Computer Science (LICS'00). 375--387. Google ScholarGoogle ScholarDigital LibraryDigital Library
  55. Xi, H. and Pfenning, F. 1999. Dependent types in practical programming. In Proceedings of the 26th ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages (PoPL'99). ACM Press, New York, 214--227. Google ScholarGoogle ScholarDigital LibraryDigital Library

Index Terms

  1. Hybrid type checking

      Recommendations

      Reviews

      Pierre Jouvelot

      Many programming languages rely on static typing systems to help software engineers catch errors as soon as possible. However, having to decide type satisfiability at compile time severely constrains the design space of such systems; more sophisticated and thus useful types could be introduced if one could delay type checking to runtime. This paper introduces hybrid type systems that rely on a static typing discipline whenever possible and only revert to runtime checks when type compatibility cannot be asserted at compile time. Hybrid type systems strive to offer the best of both worlds: advanced type safety at the lowest performance cost possible. The authors illustrate hybrid type checking on a typed lambda calculus extended with type coercion expressions that perform runtime type compatibility checks. Types are based on refinement types, which denote sets of values that verify a given arbitrary Boolean predicate. Such an expressive dependent type system is undecidable, although some checking can be performed statically, depending on the power of the Boolean theorem prover used by the type checker. In this setting, type checking a lambda calculus expression not only ensures that its subexpressions are properly typed (whenever possible), but also returns a copy of the initial expression, in which some dynamic runtime type checks may have been added (when the prover fails to be conclusive). This reconstruction algorithm and its correctness proof are provided in the paper. Designers of type systems will find this easy-to-read paper a valuable contribution to the field. 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 Transactions on Programming Languages and Systems
        ACM Transactions on Programming Languages and Systems  Volume 32, Issue 2
        January 2010
        123 pages
        ISSN:0164-0925
        EISSN:1558-4593
        DOI:10.1145/1667048
        Issue’s Table of Contents

        Copyright © 2010 ACM

        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: 8 February 2010
        • Accepted: 1 May 2009
        • Revised: 1 April 2009
        • Received: 1 July 2008
        Published in toplas Volume 32, Issue 2

        Permissions

        Request permissions about this article.

        Request Permissions

        Check for updates

        Qualifiers

        • research-article
        • Research
        • Refereed

      PDF Format

      View or Download as a PDF file.

      PDF

      eReader

      View online with eReader.

      eReader