Abstract
Intermediate data structures are widely used in functional programs. Programs which use these intermediate structures are usually a lot easier to understand, but they result in loss of efficiency at run-time. In order to reduce these run-time costs, a transformation algorithm called deforestation was proposed by Wadler which could eliminate intermediate structures. However, this transformation algorithm was formulated only for first order functional programs. In this paper, it is shown how the original deforestation algorithm can be extended to deal with higher order functional programs. A treeless form of higher order expression is defined which creates no intermediate structures. Higher order treeless form is an easily recognised form of expression, and any function definition can easily be generalised so that it is in this form. It is shown that the higher order deforestation algorithm will terminate if all function definitions are in this form. This algorithm is then compared with related work.
Preview
Unable to display preview. Download preview PDF.
References
L. Augustsson. Compiling Pattern Matching. In Functional Programming Languages and Computer Architecture, volume 201 of Lecture Notes in Computer Science, pages 368–381. Springer-Verlag, 1985.
F. Bellegarde. A Transformation System Combining Partial Evaluation with Term Rewriting. Technical Report CS/E 94-010, Dept. of Computer Science, Oregon Graduate Institute, 1994.
Wei-Ngan Chin. Automatic Methods for Program Transformation. PhD thesis, Imperial College, University of London, July 1990.
L. Damas and R. Milner. Principal Type Schemes for Functional Programs. In Proceedings of the Ninth ACM Symposium on Principles of Programming Languages, pages 207–212, 1982.
A. Gill. Cheap Deforestation for Non-Strict Functional Languages. PhD thesis, Glasgow University, September 1995.
G.W. Hamilton. Compile-Time Optimisation of Store Usage in Lazy Functional Programs. PhD thesis, University of Stirling, October 1993.
R.J.M. Hughes. Supercombinators: A New Implementation Method for Applicative Languages. In Proceedings of the ACM Conference on LISP and Functional Programming, pages 1–10, 1982.
R.J.M. Hughes. Why Functional Programming Matters. The Computer Journal, 32(2):98–107, April 1989.
T. Johnsson. Lambda Lifting: Transforming Programs to Recursive Equations. In Proceedings of the Workshop on Implementation of Functional Languages, pages 165–180, February 1985.
S. Marlow and P. Wadler. Deforestation for Higher-Order Functions. In Proceedings of the Fifth Annual Glasgow Workshop on Functional Programming, pages 154–165, July 1992.
R. Milner. A Theory of Type Polymorphism in Programming. Journal of Computer and System Science, 17:348–375, 1978.
K. Nielsen and M. H. Sørensen. Deforestation, Partial Evaluation, and Evaluation Orders. Unpublished, 1995.
D. Sands. Proving the Correctness of Recursion-Based Automatic Program Transformations. In Sixth International Conference on Theory and Practice of Software Development (TAPSOFT), volume 915 of Lecture Notes in Computer Science, pages 681–695. Springer-Verlag, 1995.
H. Seidl. Integer Constraints to Stop Deforestation. In Proceedings of the European Symposium on Programming, 1996.
M. H. Sørensen. A Grammar-Based Data-Flow Analysis to Stop Deforestation. In Lecture Notes in Computer Science, volume 787, pages 335–351, 1994.
P. Wadler. Efficient Compilation of Pattern Matching. In S.L. Peyton Jones, editor, The Implementation of Functional Programming Languages, pages 78–103. Prentice Hall, 1987.
P. Wadler. Deforestation: Transforming Programs to Eliminate Trees. Theoretical Computer Science, 73:231–248, 1990.
Author information
Authors and Affiliations
Editor information
Rights and permissions
Copyright information
© 1996 Springer-Verlag Berlin Heidelberg
About this paper
Cite this paper
Hamilton, G.W. (1996). Higher order deforestation. In: Kuchen, H., Doaitse Swierstra, S. (eds) Programming Languages: Implementations, Logics, and Programs. PLILP 1996. Lecture Notes in Computer Science, vol 1140. Springer, Berlin, Heidelberg. https://doi.org/10.1007/3-540-61756-6_87
Download citation
DOI: https://doi.org/10.1007/3-540-61756-6_87
Published:
Publisher Name: Springer, Berlin, Heidelberg
Print ISBN: 978-3-540-61756-3
Online ISBN: 978-3-540-70654-0
eBook Packages: Springer Book Archive