Abstract
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 itself. We also suggest that defunctionalization is an instance of concretization, a more general technique that allows eliminating constructs other than functions. We illustrate this point by presenting two new type-preserving transformations that can be viewed as instances of concretization. One eliminates Rémy-style polymorphic records; the other eliminates the dictionary records introduced by the standard compilation scheme for Haskell’s type classes.
Similar content being viewed by others
References
1. Banerjee, A., Heintze, N., Riecke, J.G.: Design and correctness of program transformations based on control-flow analysis. In: International Symposium on Theoretical Aspects of Computer Software (TACS), vol. 2215 of Lecture Notes in Computer Science, pp. 420–447 (2001) http://www.cis.ksu.edu/ab/Publications/pcfa.ps.gz
2. Bell, J.M., Bellegarde, F., Hook, J.: Type-driven defunctionalization. In: ACM International Conference on Functional Programming (ICFP) (1997) http://doi.acm.org/10.1145/258949.258953
3. Bonniot, D.: Type-checking multi-methods in ML (a modular approach). In: Workshop on Foundations of Object-Oriented Languages (FOOL) (2002) http://cristal.inria.fr/bonniot/bonniot02.ps
4. Boquist, U.: Code optimisation techniques for lazy functional languages. Ph.D. thesis, Chalmers University of Technology (1999) http://www.cs.chalmers.se/boquist/phd/phd.ps.gz
5. Bourdoncle, F., Merz, S.: Type checking higher-order polymorphic multi-methods. In: ACM Symposium on Principles of Programming Languages (POPL), pp. 302–315 (1997) http://www.exalead.com/Francois.Bourdoncle/popl97.html
6. Cardelli, L.: A semantics of multiple inheritance. Information and Computation 76(2/3), 138–164 (1988) http://research.microsoft.com/Users/luca/Papers/Inheritance.pdf
7. Cejtin, H., Jagannathan, S., Weeks, S.: Flow-directed closure conversion for typed languages. In: European Symposium on Programming (ESOP), vol. 1782 of Lecture Notes in Computer Science, pp. 56–71 (2000) http://mlton.org/papers/00-esop.ps.gz
8. Cheney, J., Hinze, R.: 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
9. Damas, L., Milner, R.: Principal type-schemes for functional programs. In: ACM Symposium on Principles of Programming Languages (POPL), pp. 207–212 (1982) http://doi.acm.org/10.1145/582153.582176
10. Danvy, O.: Functional unparsing. Journal of Functional Programming 8(6), 621–625 (1998)
11. Danvy, O., Nielsen, L.R.: Defunctionalization at work. In: ACM International Conference on Principles and Practice of Declarative Programming (PPDP), pp. 162–174 (2001) http://doi.acm.org/10.1145/773184.773202
12. Frey, A.: Approche algébrique du typage d’un langage á la ML avec objets, sous-typage et multi-méthodes. Ph.D. thesis, École des Mines de Paris (2004) http://pastel.rilk.com/archive/00000792/01/these-afrey.pdf
13. Furuse, J.: Extensi% onal polymorphism by flow graph dispatching. In: Asian Symposium on Programming Languages and Systems, vol. 2895 of Lecture Notes in Computer Science (2003) http://cristal.inria.fr/furuse/publications/flowgraph.ps.gz
14. Gaster, B.R., Jones, M.P.: A polymorphic type system for extensible records and variants. Technical Report NOTTCS-TR-96-3, Department of Computer Science, University of Nottingham (1996) http://www.cse.ogi.edu/mpj/pubs/polyrec.html
15. Girard, J.-Y.: Interprétation fonctionnelle et élimination des coupures de larithmétique dordre supérieur. Thése d’état, Université Paris 7 (1972)
16. Hall, C., Hammond, K., Peyton Jones, S., Wadler, P.: Type classes in Haskell. In: Sannella D. (ed.): European Symposium on Programming (ESOP), vol. 788 of Lecture Notes in Computer Science, pp. 241–256 (1994) http://research.microsoft.com/Users/simonpj/Papers/classhask.ps.gz
17. Hall, C., Hammond, K., Peyton Jones, S., Wadler, P.: Type classes in Haskell. ACM Transactions on Programming Languages and Systems 18(2), 109–138 (1996) http://doi.acm.org/10.1145/227699.227700
18. Hanus, M.: Horn clause specifications with polymorphic types. Ph.D. thesis, Fachbereich Informatik, Universität Dortmund (1988) http://www.informatik.uni-kiel.de/mh/publications/various/Dissertation.dvi.Z
19. Hanus, M.: Horn clause programs with polymorphic types: Semantics and resolution. In: International Joint Conference on Theory and Practice of Software Development (TAPSOFT), vol. 352 of Lecture Notes in Computer Science, pp. 225–240 (1989) http://www.informatik.uni-kiel.de/mh/publications/papers/TAPSOFT89.ps%
20. Hinze, R.: Fun with phantom types. In: Gibbons J., de Moor O. (eds.) The Fun of Programming. Palgrave Macmillan, pp. 245–262 (2003) http://www.informatik.uni-bonn.de/ralf/publications/With.pdf
21. Millstein, T., Chambers, C.: Modular statically typed multimethods. Information and Computation 175(1), 76–118 (2002) http://www.cs.ucla.edu/todd/research/iandc.ps
22. Milner, R.: A theory of type polymorphism in programming. Journal of Computer and System Sciences 17(3), 348–375 (1978)
23. Minamide, Y., Morrisett, G., Harper, R.: Typed closure conversion. In: ACM Symposium on Principles of Programming Languages (POPL), pp. 271–283 (1996) http://www.cs.cornell.edu/Info/People/jgm/papers/closure-summary.ps
24. Morrisett, G., Harper, R.: Typed closure conversion for recursively-defined functions (extended abstract). In: International Workshop on Higher Order Operational Techniques in Semantics (HOOTS), vol. 10 of Electronic Notes in Theoretical Computer Science (1998) http://www.cs.cornell.edu/home/jgm/papers/hootsclosure.ps
25. Morrisett, G., Walker, D., Crary, K., Glew, N.: From system F to typed assembly language. ACM Transactions on Programming Languages and Systems 21(3), 528–569 (1999) http://www.cs.cornell.edu/talc/papers/tal-toplas.pdf
26. Nielsen, L.R.: A denotational investigation of defunctionalization. Technical Report RS-00-47, BRICS (2000) http://www.brics.dk/RS/00/47/
27. Ohori, A.: A polymorphic record calculus and its compilation. ACM Transactions on Programming Languages and Systems 17(6), 844–895 (1995) http://doi.acm.org/10.1145/218570.218572
28. Paulin-Mohring, C.: 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
29. Pierce, B.C.: Types and Programming Languages. MIT Press, (2002) http://www.cis.upenn.edu/bcpierce/tapl/
30. Pottier, F., Gauthier, N.: Polymorphic typed defunctionalization. In: ACM Symposium on Principles of Programming Languages (POPL), pp. 89–98 (2004) http://cristal.inria.fr/fpottier/publis/fpottier-gauthier-popl04.pdf
31. Pottier, F., Rémy, D.: The essence of ML type inference. In: Pierce B. C. (ed.), Advanced Topics in Types and Programming Languages. MIT Press, Chapt. 10, pp. 389–489 (2005)
32. Rémy, D.: Type inference for records in a natural extension of ML. In: Gunter C. A., Mitchell J. C. (eds), Theoretical Aspects of Object-Oriented Programming. Types, Semantics and Language Design. MIT Press (1994) ftp://ftp.inria.fr/INRIA/Projects/cristal/Didier.Remy/taoop1.ps.gz
33. Reynolds, J.C.: Types, abstraction and parametric polymorphism. In: Information Processing vol. 83, pp. 513–523 (1983) ftp://ftp.cs.cmu.edu/user/jcr/typesabpara.pdf
34. Reynolds, J.C.: Definitional interpreters for higher-order programming languages. Higher-Order and Symbolic Computation 11(4), 363–397 (1998) ftp://ftp.cs.cmu.edu/user/jcr/defint.dvi.gz
35. Reynolds, J.C.: Definitional interpreters revisited. Higher-Order and Symbolic Computation 11(4), 355–361 (1998) ftp://ftp.cs.cmu.edu/user/jcr/defintintro.dvi.gz
36. Sheard, T.: Languages of the future. In: ACM Conference on Object-Oriented Programming, Systems, Languages, and Applications (OOPSLA), pp. 116–119 (2004) http://doi.acm.org/10.1145/1028664.1028711
37. Simonet, V., Pottier, F.: Constraint-based type inference for guarded algebraic data types. Research Report 5462, INRIA (2005) http://www.inria.fr/rrrt/rr-5462.html
38. Tolmach, A.: Combining closure conversion with closure analysis using algebraic types. In: Workshop on Types in Compilation (TIC) (1997) http://www.cs.pdx.edu/apt/tic97.ps
39. Tolmach, A., Oliva, D.P.: From ML to Ada: Strongly-typed language interoperability via source translation. Journal of Functional Programming 8(4), 367–412 (1998) http://www.cs.pdx.edu/apt/jfp98.ps
40. Wadler, P., Blott, S.: How to make ad-hoc polymorphism less ad-hoc. In: ACM Symposium on Principles of Programming Languages (POPL), pp. 60–76 (1989) http://homepages.inf.ed.ac.uk/wadler/papers/class/class.ps.gz
41. Warren, D.H.D.: Higher-order extensions to PROLOG: are they needed?. In: Hayes J. E., Michie D., Pao Y.-H. (eds.) Machine Intelligence 10. Ellis Horwood, pp. 441–454 (1982)
42. Xi, H.: Dead code elimination through dependent types. In: International Workshop on Practical Aspects of Declarative Languages (PADL), vol. 1551 of Lecture Notes in Computer Science, pp. 228–242 (1999) http://www.cs.bu.edu/hwxi/academic/papers/padl99.ps
43. Xi, H.: Applied type system. In: TYPES 2003, vol. 3085 of Lecture Notes in Computer Science, pp. 394–408 (2004) http://www.cs.bu.edu/hwxi/academic/papers/types03.pdf
44. Xi, H., Chen, C., Chen, G.: Guarded recursive datatype constructors. In: ACM Symposium on Principles of Programming Languages (POPL), pp. 224–235 (2003) http://www.cs.bu.edu/fac/hwxi/academic/papers/popl03.ps
45. Zendra, O., Colnet, D., Collin, S.: Efficient dynamic dispatch without virtual function tables. the SmallEiffel compiler. In: ACM Conference on Object-Oriented Programming, Systems, Languages, and Applications (OOPSLA), pp. 125–141 (1997) http://www.loria.fr/colnet/publis/oopsla97.ps.gz
46. Zibin, Y., Gil, Y.: Fast algorithm for creating space efficient dispatching tables with application to multi-dispatching. In: ACM Conference on Object-Oriented Programming, Systems, Languages, and Applications (OOPSLA), pp. 142–160 (2002) http://www.cs.technion.ac.il/zyoav/publications/OOPSLA02-dispatching-TS.pdf
Author information
Authors and Affiliations
Additional information
This is a revised and extended version of an earlier conference paper[30].
Rights and permissions
About this article
Cite this article
Pottier, F., Gauthier, N. Polymorphic typed defunctionalization and concretization. Higher-Order Symb Comput 19, 125–162 (2006). https://doi.org/10.1007/s10990-006-8611-7
Issue Date:
DOI: https://doi.org/10.1007/s10990-006-8611-7