The Generalized Intensional Transformation for Implementing Lazy Functional Languages
Abstract
The intensional transformation is a promising technique for implementing lazy functional languages based on a demand-driven execution model. Despite its theoretical elegance and its simple and efficient execution model, the intensional transformation suffered, until now, from two main drawbacks: it could only be applied to programs that manipulate primitive data-types and it could only compile a simple (and rather restricted) class of higher-order functions. In this paper we remedy the above two deficiencies, obtaining a transformation algorithm that is applicable to mainstream lazy functional languages. The proposed transformation initially uses defunctionalization in order to eliminate higher-order functions from the source program. The original intensional transformation is then extended in order to apply to the target first-order language with user-defined data types that resulted from the defunctionalization. It is demonstrated that the proposed technique can be used to compile a relatively large subset of Haskell into portable C code whose performance is comparable to existing mainstream implementations.
Keywords
intensional transformation dataflow programming defunctionalization compilation lazy functional languagesPreview
Unable to display preview. Download preview PDF.
References
- 1.Arvind, R.S.N.: Executing a program on the MIT tagged-token dataflow architecture. IEEE Transactions on Computers 39, 300–318 (1990)CrossRefGoogle Scholar
- 2.Ashcroft, E.A., Faustini, A.A., Jagannathan, R., Wadge, W.W.: Multidimensional Programming. Oxford University Press (1995)Google Scholar
- 3.Boquist, U., Johnsson, T.: The GRIN project: A highly optimising back end for lazy functional languages. In: Kluge, W. (ed.) IFL 1996. LNCS, vol. 1268, pp. 58–84. Springer, Heidelberg (1997)CrossRefGoogle Scholar
- 4.Charalambidis, A., Grivas, A., Papaspyrou, N.S., Rondogiannis, P.: Efficient intensional implementation for lazy functional languages. Mathematics in Computer Science 2(1), 123–141 (2008)MathSciNetCrossRefzbMATHGoogle Scholar
- 5.De La Encina, A., Peña, R.: From natural semantics to C: A formal derivation of two STG machines. Journal of Functional Programming 19(1), 47–94 (2009)MathSciNetCrossRefzbMATHGoogle Scholar
- 6.Fourtounis, G., Papaspyrou, N., Rondogiannis, P.: The intensional transformation for functional languages with user-defined data types. In: Proceedings of the 8th Panhellenic Logic Symposium, pp. 38–42 (2011)Google Scholar
- 7.Friedman, D.P., Wise, D.S.: CONS should not evaluate its arguments. In: Proceedings of the International Colloquium on Automata, Languages and Programming, pp. 257–284 (1976)Google Scholar
- 8.Henderson, P., Jr. Morris, J.H.: A lazy evaluator. In: Proceedings of the 3rd ACM SIGACT-SIGPLAN Symposium on Principles on Programming Languages, pp. 95–103. ACM, New York (1976)Google Scholar
- 9.Kirkham, C., Gurd, J., Watson, I.: The Manchester prototype dataflow computer. Communications of the ACM, 34–52 (1985)Google Scholar
- 10.Krivine, J.L.: Un interpréteur du lambda-calcul, http://www.pps.univ-paris-diderot.fr/~krivine/articles/interprt.pdf
- 11.Partain, W.: The nofib benchmark suite of Haskell programs. In: Proceedings of the 1992 Glasgow Workshop on Functional Programming, pp. 195–202 (1993)Google Scholar
- 12.Pingali, K.: Lazy evaluation and the logic variable. In: Proceedings of the 2nd International Conference on Supercomputing, pp. 560–572. ACM, New York (1988)Google Scholar
- 13.Plaice, J., Mancilla, B.: The practical uses of TransLucid. In: Proceedings of the 1st International Workshop on Context-aware Software Technology and Applications, pp. 13–16. ACM, New York (2009)Google Scholar
- 14.Pottier, F., Gauthier, N.: Polymorphic typed defunctionalization and concretization. Higher-Order and Symbolic Computation 19, 125–162 (2006)CrossRefzbMATHGoogle Scholar
- 15.Reynolds, J.C.: Definitional interpreters for higher-order programming languages. In: Proceedings of the 25th ACM National Conference, pp. 717–740. ACM (1972)Google Scholar
- 16.Rondogiannis, P., Wadge, W.W.: First-order functional languages and intensional logic. Journal of Functional Programming 7(1), 73–101 (1997)MathSciNetCrossRefzbMATHGoogle Scholar
- 17.Rondogiannis, P., Wadge, W.W.: Higher-order functional languages and intensional logic. Journal of Functional Programming 9(5), 527–564 (1999)MathSciNetCrossRefzbMATHGoogle Scholar
- 18.Traub, K.R.: A compiler for the MIT tagged-token dataflow architecture. Technical report, Massachusetts Institute of Technology, Cambridge, MA, USA (1986)Google Scholar
- 19.Wadge, W., Aschroft, E.A.: Lucid, the Dataflow Programming Language. Academic Press (1985)Google Scholar
- 20.Yaghi, A.A.: The Intensional Implementation Technique for Functional Languages. Ph.D. thesis, Department of Computer Science, University of Warwick, Coventry, UK (1984)Google Scholar