skip to main content
research-article
Public Access

Typed self-evaluation via intensional type functions

Published:01 January 2017Publication History
Skip Abstract Section

Abstract

Many popular languages have a self-interpreter, that is, an interpreter for the language written in itself. So far, work on polymorphically-typed self-interpreters has concentrated on self-recognizers that merely recover a program from its representation. A larger and until now unsolved challenge is to implement a polymorphically-typed self-evaluator that evaluates the represented program and produces a representation of the result. We present Fωμi, the first λ-calculus that supports a polymorphically-typed self-evaluator. Our calculus extends Fω with recursive types and intensional type functions and has decidable type checking. Our key innovation is a novel implementation of type equality proofs that enables us to define a versatile representation of programs. Our results establish a new category of languages that can support polymorphically-typed self-evaluators.

References

  1. Martin Abadi, Luca Cardelli, and Gordon Plotkin. Types for the scott numerals, 1993.Google ScholarGoogle Scholar
  2. Harold Abelson, Gerald Jay Sussman, and Julie Sussman. Structure and Interpretation of Computer Programs. MIT Press, 1985. Google ScholarGoogle ScholarDigital LibraryDigital Library
  3. Klaus Aehlig and Felix Joachimski. Operational aspects of untyped normalisation by evaluation. Mathematical Structures in Computer Science, 14:587–611, 8 2004. Google ScholarGoogle ScholarDigital LibraryDigital Library
  4. Arthur I. Baars and S. Doaitse Swierstra. Typing dynamic typing. In ICFP ’02: Proceedings of the 7th ACM SIGPLAN International Conference on Functional Programming, pages 157–166. ACM Press, 2002. Google ScholarGoogle ScholarDigital LibraryDigital Library
  5. Reg Braithwaite. The significance of the meta-circular interpreter. http://weblog.raganwald.com/2006/11/significance-of-metacircular_22.html, November 2006.Google ScholarGoogle Scholar
  6. Matt Brown and Jens Palsberg. Self-Representation in Girard’s System U. In Proceedings of the 42nd Annual ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages, POPL ’15, pages 471– 484, New York, NY, USA, 2015. ACM. Google ScholarGoogle ScholarDigital LibraryDigital Library
  7. Matt Brown and Jens Palsberg. Breaking through the normalization barrier: A self-interpreter for F-omega. In Proceedings of the 43rd Annual ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages, POPL 2016, pages 5–17, New York, NY, USA, 2016. ACM. Google ScholarGoogle ScholarDigital LibraryDigital Library
  8. Chiyan Chen, Dengping Zhu, and Hongwei Xi. Implementing Cut Elimination: A Case Study of Simulating Dependent Types in Haskell, pages 239–254. Springer Berlin Heidelberg, Berlin, Heidelberg, 2004.Google ScholarGoogle Scholar
  9. James Cheney and Ralf Hinze. A lightweight implementation of generics and dynamics. In Proceedings of the 2002 ACM SIGPLAN Workshop on Haskell, Haskell ’02, pages 90–104, New York, NY, USA, 2002. ACM. Google ScholarGoogle ScholarDigital LibraryDigital Library
  10. James Cheney and Ralf Hinze. First-class phantom types. Technical report, Cornell University, 2003.Google ScholarGoogle Scholar
  11. Adam Chlipala. Parametric higher-order abstract syntax for mechanized semantics. In Proceedings of the 13th ACM SIGPLAN International Conference on Functional Programming, ICFP ’08, pages 143– 156, New York, NY, USA, 2008. ACM. Google ScholarGoogle ScholarDigital LibraryDigital Library
  12. Gregory D. Collins and Zhong Shao. Intensional analysis of higherkinded recursive types. Technical report, Yale University, 2002.Google ScholarGoogle Scholar
  13. Karl Crary and Stephanie Weirich. Flexible type analysis. In In 1999 ACM International Conference on Functional Programming, pages 233–248. ACM Press, 1999. Google ScholarGoogle ScholarDigital LibraryDigital Library
  14. Karl Crary, Stephanie Weirich, and Greg Morrisett. Intensional polymorphism in type-erasure semantics. SIGPLAN Not., 34(1):301–312, September 1998. Google ScholarGoogle ScholarDigital LibraryDigital Library
  15. Dominic Duggan. A type-based semantics for user-defined marshalling in polymorphic languages, pages 273–297. Springer Berlin Heidelberg, Berlin, Heidelberg, 1998. Google ScholarGoogle ScholarDigital LibraryDigital Library
  16. Brendan Eich. Narcissus. http://mxr.mozilla.org/mozilla/ source/js/narcissus/jsexec.js, 2010.Google ScholarGoogle Scholar
  17. Andrzej Filinski and Henning Korsholm Rohde. A Denotational Account of Untyped Normalization by Evaluation, pages 167–181. Springer Berlin Heidelberg, Berlin, Heidelberg, 2004.Google ScholarGoogle Scholar
  18. Jean-Yves Girard, Paul Taylor, and Yves Lafont. Proofs and Types. Number 7 in Cambridge Tracts in Theoretical Computer Science. Cambridge University Press, 1989. Google ScholarGoogle ScholarDigital LibraryDigital Library
  19. Louis-Julien Guillemette and Stefan Monnier. A type-preserving compiler in Haskell. In Proceedings of the 13th ACM SIGPLAN international conference on Functional programming, ICFP ’08, pages 75–86, New York, NY, USA, 2008. ACM. Google ScholarGoogle ScholarDigital LibraryDigital Library
  20. Robert Harper and Greg Morrisett. Compiling polymorphism using intensional type analysis. In Proceedings of the 22Nd ACM SIGPLANSIGACT Symposium on Principles of Programming Languages, POPL ’95, pages 130–141, New York, NY, USA, 1995. ACM. Google ScholarGoogle ScholarDigital LibraryDigital Library
  21. Barry Jay and Jens Palsberg. Typed self-interpretation by pattern matching. In Proceedings of ICFP’11, ACM SIGPLAN International Conference on Functional Programming, pages 247–258, Tokyo, September 2011. Google ScholarGoogle ScholarDigital LibraryDigital Library
  22. Arie Middelkoop, Atze Dijkstra, and S. Doaitse Swierstra. A lean specification for GADTs: System F with first-class equality proofs. Higher Order Symbol. Comput., 23(2):145–166, June 2010. Google ScholarGoogle ScholarDigital LibraryDigital Library
  23. Torben Æ. Mogensen. Efficient self-interpretations in lambda calculus. Journal of Functional Programming, 2(3):345–363, 1992. See also DIKU Report D–128, Sep 2, 1994.Google ScholarGoogle ScholarCross RefCross Ref
  24. Greg Morrisett. Compiling with types. Technical report, 1995.Google ScholarGoogle Scholar
  25. Matthew Naylor. Evaluating Haskell in Haskell. The Monad.Reader, 10:25–33, 2008.Google ScholarGoogle Scholar
  26. Georg Neis, Derek Dreyer, and Andreas Rossberg. Non-parametric parametricity. In Proceedings of the 14th ACM SIGPLAN International Conference on Functional Programming, ICFP ’09, pages 135–148, New York, NY, USA, 2009. ACM. Google ScholarGoogle ScholarDigital LibraryDigital Library
  27. Emir Pasalic. The Role of Type Equality in Meta-programming. PhD thesis, 2004. AAI3151199. Google ScholarGoogle ScholarDigital LibraryDigital Library
  28. Frank Pfenning and Peter Lee. Metacircularity in the polymorphic λcalculus. Theoretical Computer Science, 89(1):137–159, 1991. Google ScholarGoogle ScholarDigital LibraryDigital Library
  29. Benjamin C. Pierce. Types and Programming Languages. MIT Press, Cambridge, MA, USA, 2002. Google ScholarGoogle ScholarDigital LibraryDigital Library
  30. Tillmann Rendel, Klaus Ostermann, and Christian Hofer. Typed selfrepresentation. In Proceedings of PLDI’09, ACM SIGPLAN Conference on Programming Language Design and Implementation, pages 293–303, June 2009. Google ScholarGoogle ScholarDigital LibraryDigital Library
  31. Armin Rigo and Samuele Pedroni. Pypy’s approach to virtual machine construction. In OOPSLA Companion, pages 044–953, 2006. Google ScholarGoogle ScholarDigital LibraryDigital Library
  32. Andreas Rossberg. HaMLet. http://www.mpi-sws.org/ rossberg/hamlet, 2010.Google ScholarGoogle Scholar
  33. Bratin Saha, Valery Trifonov, and Zhong Shao. Intensional analysis of quantified types. ACM Trans. Program. Lang. Syst., 25(2):159–209, 2003. Google ScholarGoogle ScholarDigital LibraryDigital Library
  34. Tim Sheard and Emir Pasalic. Meta-programming with built-in type equality. Electron. Notes Theor. Comput. Sci., 199:49–65, February 2008. Google ScholarGoogle ScholarDigital LibraryDigital Library
  35. Martin Sulzmann, Manuel M. T. Chakravarty, Simon Peyton Jones, and Kevin Donnelly. System F with type equality coercions. In TLDI’07, ACM SIGPLAN Workshop on Types in Language Design and Implementation, 2007. Google ScholarGoogle ScholarDigital LibraryDigital Library
  36. Valery Trifonov, Bratin Saha, and Zhong Shao. Fully reflexive intensional type analysis. SIGPLAN Not., 35(9):82–93, September 2000. Google ScholarGoogle ScholarDigital LibraryDigital Library
  37. Dimitrios Vytiniotis, Geoffrey Washburn, and Stephanie Weirich. An open and shut typecase. In Proceedings of the 2005 ACM SIGPLAN International Workshop on Types in Languages Design and Implementation, TLDI ’05, pages 13–24, New York, NY, USA, 2005. ACM. Google ScholarGoogle ScholarDigital LibraryDigital Library
  38. Dimitrios Vytiniotis and Stephanie Weirich. Parametricity, type equality, and higher-order polymorphism. Journal of Functional Programming, 20(02):175–210, 2010. Google ScholarGoogle ScholarDigital LibraryDigital Library
  39. Geoffrey Washburn and Stephanie Weirich. Boxes go bananas: Encoding higher-order abstract syntax with parametric polymorphism. In Proceedings of the Eighth ACM SIGPLAN International Conference on Functional Programming, ICFP ’03, pages 249–262, New York, NY, USA, 2003. ACM. Google ScholarGoogle ScholarDigital LibraryDigital Library
  40. Stephanie Weirich. Type-safe cast: (functional pearl). In Proceedings of the Fifth ACM SIGPLAN International Conference on Functional Programming, ICFP ’00, pages 58–67, New York, NY, USA, 2000. ACM. Google ScholarGoogle ScholarDigital LibraryDigital Library
  41. Stephanie Weirich. Higher-order intensional type analysis. In Proceedings of the 11th European Symposium on Programming Languages and Systems, ESOP ’02, pages 98–114, London, UK, UK, 2002. Springer-Verlag. Google ScholarGoogle ScholarDigital LibraryDigital Library
  42. Wikipedia. Mogensen-Scott encoding. https://en.wikipedia.org/wiki/Mogensen–Scott_encoding.Google ScholarGoogle Scholar
  43. Wikipedia. Rubinius. http://en.wikipedia.org/wiki/Rubinius, 2010.Google ScholarGoogle Scholar
  44. Andrew Wright and Matthias Felleisen. A syntactic approach to type soundness. Information and Computation, 115(1):38–94, 1994. Google ScholarGoogle ScholarDigital LibraryDigital Library
  45. Hongwei Xi, Chiyan Chen, and Gang Chen. Guarded recursive datatype constructors. In ACM SIGPLAN Notices, volume 38, pages 224–235. ACM, 2003. Google ScholarGoogle ScholarDigital LibraryDigital Library
  46. Zhe Yang. Encoding types in ML-like languages. In Proceedings of the Third ACM SIGPLAN International Conference on Functional Programming, ICFP ’98, pages 289–300, New York, NY, USA, 1998. ACM. Google ScholarGoogle ScholarDigital LibraryDigital Library

Index Terms

  1. Typed self-evaluation via intensional type functions

        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

        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!