Skip to main content

Higher order deforestation

  • Program Transformation
  • Conference paper
  • First Online:
Programming Languages: Implementations, Logics, and Programs (PLILP 1996)

Part of the book series: Lecture Notes in Computer Science ((LNCS,volume 1140))

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.

This is a preview of subscription content, log in via an institution to check access.

Access this chapter

Institutional subscriptions

Preview

Unable to display preview. Download preview PDF.

Unable to display preview. Download preview PDF.

References

  1. 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.

    Google Scholar 

  2. 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.

    Google Scholar 

  3. Wei-Ngan Chin. Automatic Methods for Program Transformation. PhD thesis, Imperial College, University of London, July 1990.

    Google Scholar 

  4. 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.

    Google Scholar 

  5. A. Gill. Cheap Deforestation for Non-Strict Functional Languages. PhD thesis, Glasgow University, September 1995.

    Google Scholar 

  6. G.W. Hamilton. Compile-Time Optimisation of Store Usage in Lazy Functional Programs. PhD thesis, University of Stirling, October 1993.

    Google Scholar 

  7. 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.

    Google Scholar 

  8. R.J.M. Hughes. Why Functional Programming Matters. The Computer Journal, 32(2):98–107, April 1989.

    Google Scholar 

  9. T. Johnsson. Lambda Lifting: Transforming Programs to Recursive Equations. In Proceedings of the Workshop on Implementation of Functional Languages, pages 165–180, February 1985.

    Google Scholar 

  10. 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.

    Google Scholar 

  11. R. Milner. A Theory of Type Polymorphism in Programming. Journal of Computer and System Science, 17:348–375, 1978.

    Google Scholar 

  12. K. Nielsen and M. H. Sørensen. Deforestation, Partial Evaluation, and Evaluation Orders. Unpublished, 1995.

    Google Scholar 

  13. 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.

    Google Scholar 

  14. H. Seidl. Integer Constraints to Stop Deforestation. In Proceedings of the European Symposium on Programming, 1996.

    Google Scholar 

  15. 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.

    Google Scholar 

  16. 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.

    Google Scholar 

  17. P. Wadler. Deforestation: Transforming Programs to Eliminate Trees. Theoretical Computer Science, 73:231–248, 1990.

    Google Scholar 

Download references

Author information

Authors and Affiliations

Authors

Editor information

Herbert Kuchen S. Doaitse Swierstra

Rights and permissions

Reprints 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

Publish with us

Policies and ethics