skip to main content
research-article

Ur: statically-typed metaprogramming with type-level record computation

Published:05 June 2010Publication History
Skip Abstract Section

Abstract

Dependent types provide a strong foundation for specifying and verifying rich properties of programs through type-checking. The earliest implementations combined dependency, which allows types to mention program variables; with type-level computation, which facilitates expressive specifications that compute with recursive functions over types. While many recent applications of dependent types omit the latter facility, we argue in this paper that it deserves more attention, even when implemented without dependency.

In particular, the ability to use functional programs as specifications enables statically-typed metaprogramming: programs write programs, and static type-checking guarantees that the generating process never produces invalid code. Since our focus is on generic validity properties rather than full correctness verification, it is possible to engineer type inference systems that are very effective in narrow domains. As a demonstration, we present Ur, a programming language designed to facilitate metaprogramming with first-class records and names. On top of Ur, we implement Ur/Web, a special standard library that enables the development of modern Web applications. Ad-hoc code generation is already in wide use in the popular Web application frameworks, and we show how that generation may be tamed using types, without forcing metaprogram authors to write proofs or forcing metaprogram users to write any fancy types.

References

  1. Thorsten Altenkirch and Conor McBride. Generic programming within dependently typed programming. In Proc. IFIP TC2/WG2.1 Working Conference on Generic Programming, 2003. Google ScholarGoogle ScholarDigital LibraryDigital Library
  2. Lennart Augustsson. Cayenne - a language with dependent types. In Proc. ICFP, 1998. Google ScholarGoogle ScholarDigital LibraryDigital Library
  3. Yves Bertot and Pierre Castéran. Interactive Theorem Proving and Program Development. Coq'Art: The Calculus of Inductive Constructions. Texts in Theoretical Computer Science. Springer Verlag, 2004. Google ScholarGoogle ScholarDigital LibraryDigital Library
  4. Matthias Blume, Umut A. Acar, and Wonseok Chae. Extensible programming with first-class cases. In Proc. ICFP, 2006. Google ScholarGoogle ScholarDigital LibraryDigital Library
  5. Chiyan Chen and Hongwei Xi. Combining programming with theorem proving. In Proc. ICFP, 2005. Google ScholarGoogle ScholarDigital LibraryDigital Library
  6. Jeremy Condit, Matthew Harren, Zachary Anderson, David Gay, and George Necula. Dependent types for low-level programming. In Proc. ESOP, 2007. Google ScholarGoogle ScholarDigital LibraryDigital Library
  7. Web Application Security Consortium. 2007 Web application security statistics. http://projects.webappsec.org/Web-Application-Security-Statistics.Google ScholarGoogle Scholar
  8. Manuel Fähndrich, Michael Carbin, and James R. Larus. Reflective program generation with patterns. In Proc. GPCE, 2006. Google ScholarGoogle ScholarDigital LibraryDigital Library
  9. Benedict R. Gaster and Mark P. Jones. A polymorphic type system for extensible records and variants. Technical Report NOTTCS-TR-96-3, University of Nottingham, 1996.Google ScholarGoogle Scholar
  10. Robert Harper and Benjamin Pierce. A record calculus based on symmetric concatenation. In Proc. POPL, 1991. Google ScholarGoogle ScholarDigital LibraryDigital Library
  11. Shan Shan Huang and Yannis Smaragdakis. Expressive and safe static reflection with MorphJ. In Proc. PLDI, 2008. Google ScholarGoogle ScholarDigital LibraryDigital Library
  12. Mark P. Jones. Type classes with functional dependencies. In Proc. ESOP, 2000. Google ScholarGoogle ScholarDigital LibraryDigital Library
  13. Oleg Kiselyov, Ralf Lämmel, and Keean Schupke. Strongly typed heterogeneous collections. In Proc. Haskell Workshop, 2004. Google ScholarGoogle ScholarDigital LibraryDigital Library
  14. Kenneth Knowles, Aaron Tomb, Jessica Gronski, Stephen N. Freund, and Cormac Flanagan. Sage: Unified hybrid checking for first-class types, general refinement types, and Dynamic. In Proc. Scheme Workshop, 2006.Google ScholarGoogle Scholar
  15. Daan Leijen and Erik Meijer. Domain specific embedded compilers. In Proc. DSL, 1999. Google ScholarGoogle ScholarDigital LibraryDigital Library
  16. David MacQueen. Modules for Standard ML. In Proc. LFP, 1984. Google ScholarGoogle ScholarDigital LibraryDigital Library
  17. Ulf Norell. Towards a practical programming language based on dependent type theory. PhD thesis, Chalmers University of Technology, 2007.Google ScholarGoogle Scholar
  18. Atsushi Ohori. A polymorphic record calculus and its compilation. TOPLAS, 17(6), 1995. Google ScholarGoogle ScholarDigital LibraryDigital Library
  19. Atsushi Ohori and Peter Buneman. Type inference in a database programming language. In Proc. LFP, 1988. Google ScholarGoogle ScholarDigital LibraryDigital Library
  20. Christine Paulin-Mohring. Inductive definitions in the system Coq - rules and properties. In Proc. TLCA, 1993. Google ScholarGoogle ScholarDigital LibraryDigital Library
  21. Frank Pfenning. Partial polymorphic type inference and higher-order unification. In Proc. LFP, 1988. Google ScholarGoogle ScholarDigital LibraryDigital Library
  22. Benjamin C. Pierce. Higher-order polymorphism. In Types and Programming Languages, chapter 30. MIT Press, 2002.Google ScholarGoogle ScholarDigital LibraryDigital Library
  23. François Pottier. A 3-part type inference engine. In Proc. ESOP, 2000. Google ScholarGoogle ScholarDigital LibraryDigital Library
  24. Didier Rémy. Type inference for records in a natural extension of ML. Theoretical Aspects of Object-Oriented Programming, 1994.Google ScholarGoogle ScholarDigital LibraryDigital Library
  25. Patrick Rondon, Ming Kawaguchi, and Ranjit Jhala. Liquid types. In Proc. PLDI, 2008. Google ScholarGoogle ScholarDigital LibraryDigital Library
  26. Tom Schrijvers, Simon Peyton Jones, Manuel Chakravarty, and Martin Sulzmann. Type checking with open type functions. In Proc. ICFP, 2008. Google ScholarGoogle ScholarDigital LibraryDigital Library
  27. Tom Schrijvers, Simon Peyton Jones, Martin Sulzmann, and Dimitrios Vytiniotis. Complete and decidable type inference for GADTs. In Proc. ICFP, 2009. Google ScholarGoogle ScholarDigital LibraryDigital Library
  28. Zhong Shao, Christopher League, and Stefan Monnier. Implementing typed intermediate languages. In Proc. ICFP, 1998. Google ScholarGoogle ScholarDigital LibraryDigital Library
  29. Tim Sheard. Languages of the future. In Proc. OOPSLA, 2004. Google ScholarGoogle ScholarDigital LibraryDigital Library
  30. Alexandra Silva and Joost Visser. Strong types for relational databases. In Proc. Haskell Workshop, 2006. Google ScholarGoogle ScholarDigital LibraryDigital Library
  31. Mitchell Wand. Type inference for record concatenation and multiple inheritance. Information and Computation, 93(1), 1991. Google ScholarGoogle ScholarDigital LibraryDigital Library
  32. J. B. Wells. Typability and type checking in System F are equivalent and undecidable. Annals of Pure and Applied Logic, 98:111--156, 1999.Google ScholarGoogle ScholarCross RefCross Ref
  33. Hongwei Xi. Dependent ML: an approach to practical programming with dependent types. J. Functional Programming, 17(2):215--286, 2007. Google ScholarGoogle ScholarDigital LibraryDigital Library

Index Terms

  1. Ur: statically-typed metaprogramming with type-level record computation

      Recommendations

      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 45, Issue 6
        PLDI '10
        June 2010
        496 pages
        ISSN:0362-1340
        EISSN:1558-1160
        DOI:10.1145/1809028
        Issue’s Table of Contents
        • cover image ACM Conferences
          PLDI '10: Proceedings of the 31st ACM SIGPLAN Conference on Programming Language Design and Implementation
          June 2010
          514 pages
          ISBN:9781450300193
          DOI:10.1145/1806596

        Copyright © 2010 ACM

        Publisher

        Association for Computing Machinery

        New York, NY, United States

        Publication History

        • Published: 5 June 2010

        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!