ABSTRACT
Defunctionalization is a program transformation that aims to turn a higher-order functional program into a first-order one, that is, to eliminate the use of functions as first-class values. Its purpose is thus identical to that of closure conversion. It differs from closure conversion, however, by storing a tag, instead of a code pointer, within every closure. Defunctionalization has been used both as a reasoning tool and as a compilation technique.Defunctionalization is commonly defined and studied in the setting of a simply-typed λ-calculus, where it is shown that semantics and well-typedness are preserved. It has been observed that, in the setting of a polymorphic type system, such as ML or System F, defunctionalization is not type-preserving. In this paper, we show that extending System F with guarded algebraic data types allows recovering type preservation. This result allows adding defunctionalization to the toolbox of type-preserving compiler writers.
- Anindya Banerjee, Nevin Heintze, and Jon G. Riecke. Design and correctness of program transformations based on control-flow analysis. In International Symposium on Theoretical Aspects of Computer Software (TACS), volume 2215 of Lecture Notes in Computer Science, pages 420--447. Springer Verlag, October 2001. http://www.cis.ksu.edu/~ab/Publications/pcfa.ps.gz.]] Google ScholarDigital Library
- Jeffrey M. Bell, Françoise Bellegarde, and James Hook. Type-driven defunctionalization. In ACM International Conference on Functional Programming (ICFP), August 1997. http://doi.acm.org/10.1145/258949.258953.]] Google ScholarDigital Library
- Henry Cejtin, Suresh Jagannathan, and Stephen Weeks. Flow-directed closure conversion for typed languages. In European Symposium on Programming (ESOP), volume 1782 of Lecture Notes in Computer Science, pages 56--71. Springer Verlag, March 2000. http://www.mlton.org/papers/00-esop.ps.gz.]] Google ScholarDigital Library
- James Cheney and Ralf Hinze. First-class phantom types. Technical Report 1901, Cornell University, 2003. http://techreports.library.cornell.edu:8081/Dienst/UI/1.0/Display/cul.cis/TR2003-1901.]]Google Scholar
- Olivier Danvy. Functional unparsing. Journal of Functional Programming, 8(6):621--625, November 1998.]] Google ScholarDigital Library
- Olivier Danvy and Lasse R. Nielsen. Defunctionalization at work. In ACM International Conference on Principles and Practice of Declarative Programming (PPDP), pages 162--174, September 2001.]] Google ScholarDigital Library
- Cormac Flanagan, Amr Sabry, Bruce F. Duba, and Matthias Felleisen. The essence of compiling with continuations. In ACM Conference on Programming Language Design and Implementation (PLDI), pages 237--247, 1993. http://www.cs.rice.edu/CS/PLT/Publications/Scheme/pldi93-fsdf.ps.gz.]] Google ScholarDigital Library
- Yasuhiko Minamide, Greg Morrisett, and Robert Harper. Typed closure conversion. In ACM Symposium on Principles of Programming Languages (POPL), pages 271--283, January 1996. http://www.cs.cornell.edu/Info/People/jgm/papers/closure-summary.ps.]] Google ScholarDigital Library
- Greg Morrisett and Robert Harper. Typed closure conversion for recursively-defined functions (extended abstract). In International Workshop on Higher Order Operational Techniques in Semantics (HOOTS), volume 10 of Electronic Notes in Theoretical Computer Science. Elsevier Science, 1998. http://www.cs.cornell.edu/home/jgm/papers/hootsclosure.ps.]]Google Scholar
- Greg Morrisett, David Walker, Karl Crary, and Neal Glew. From system F to typed assembly language. ACM Transactions on Programming Languages and Systems, 21(3):528--569, May 1999. http://www.cs.cornell.edu/talc/papers/tal-toplas.pdf.]] Google ScholarDigital Library
- Lasse R. Nielsen. A denotational investigation of defunctionalization. Technical Report RS-00-47, BRICS, December 2000. http://www.brics.dk/RS/00/47/.]]Google Scholar
- Christine Paulin-Mohring. Inductive definitions in the system coq: Rules and properties. Research Report RR1992-49, ENS Lyon, 1992. ftp://ftp.ens-lyon.fr/pub/LIP/Rapports/RR/RR1992/RR1992-49.ps.Z.]]Google Scholar
- John C. Reynolds. Definitional interpreters for higher-order programming languages. Higher-Order and Symbolic Computation, 11(4):363--397, December 1998. ftp://ftp.cs.cmu.edu/user/jcr/defint.dvi.gz.]] Google ScholarDigital Library
- John C. Reynolds. Definitional interpreters revisited. Higher-Order and Symbolic Computation, 11(4):355--361, December 1998. ftp://ftp.cs.cmu.edu/user/jcr/defintintro.dvi.gz.]] Google ScholarDigital Library
- Andrew Tolmach. Combining closure conversion with closure analysis using algebraic types. In Workshop on Types in Compilation (TIC), June 1997. http://www.cs.pdx.edu/~apt/tic97.ps.]]Google Scholar
- Andrew Tolmach and Dino P. Oliva. From ML to Ada: Strongly-typed language interoperability via source translation. Journal of Functional Programming, 8(4):367--412, July 1998. http://www.cs.pdx.edu/~apt/jfp98.ps.]] Google ScholarDigital Library
- Hongwei Xi. Dead code elimination through dependent types. In International Workshop on Practical Aspects of Declarative Languages (PADL), volume 1551 of Lecture Notes in Computer Science, pages 228--242. Springer Verlag, January 1999. http://www.cs.bu.edu/~hwxi/academic/papers/padl99.ps.]] Google ScholarDigital Library
- Hongwei Xi, Chiyan Chen, and Gang Chen. Guarded recursive datatype constructors. In ACM Symposium on Principles of Programming Languages (POPL), January 2003. http://www.cs.bu.edu/fac/hwxi/academic/papers/popl03.ps.]] Google ScholarDigital Library
Index Terms
- Polymorphic typed defunctionalization
Recommendations
Polymorphic typed defunctionalization
POPL '04Defunctionalization is a program transformation that aims to turn a higher-order functional program into a first-order one, that is, to eliminate the use of functions as first-class values. Its purpose is thus identical to that of closure conversion. It ...
Polymorphic typed defunctionalization and concretization
Defunctionalization is a program transformation that eliminates functions as first-class values. We show that defunctionalization can be viewed as a type-preserving transformation of an extension of F with guarded algebraic data types into ...
Typed closure conversion for the calculus of constructions
PLDI 2018: Proceedings of the 39th ACM SIGPLAN Conference on Programming Language Design and ImplementationDependently typed languages such as Coq are used to specify and verify the full functional correctness of source programs. Type-preserving compilation can be used to preserve these specifications and proofs of correctness through compilation into the ...
Comments