Advertisement

Watch Out for that Tree! A Tutorial on Shortcut Deforestation

  • João Paulo FernandesEmail author
  • Jácome Cunha
  • João Saraiva
  • Alberto Pardo
Chapter
Part of the Lecture Notes in Computer Science book series (LNCS, volume 10094)

Abstract

Functional programmers are strong enthusiasts of modular solutions to programming problems. Since software characteristics such as readability or maintainability are often directly proportional to modularity, this programming style naturally contributes to the beauty of functional programs. Unfortunately, in return of this beauty we often sacrifice efficiency: modular programs rely, at runtime, on the creation, use and elimination of intermediate data structures to connect its components. In this tutorial paper, we study an advanced technique that attempts to retain the best of this two worlds: (i) it allows programmers to implement beautiful, modular programs (ii) it shows how to transform such programs, in a way that can be incorporated in a compiler, into programs that do not construct any intermediate structure.

References

  1. Abramsky, S., Jung, A.: Domain Theory. In: Handbook of Logic in Computer Science, pp. 1–168. Clarendon Press (1994)Google Scholar
  2. Augusteijn, L.: Sorting morphisms. In: Swierstra, S.D., Oliveira, J.N., Henriques, P.R. (eds.) AFP 1998. LNCS, vol. 1608, pp. 1–27. Springer, Heidelberg (1999).  https://doi.org/10.1007/10704973_1CrossRefGoogle Scholar
  3. Bird, R.: Using circular programs to eliminate multiple traversals of data. Acta Informatica 21, 239–250 (1984)CrossRefGoogle Scholar
  4. Bird, R.: Introduction to Functional Programming using Haskell, 2nd edn. Prentice-Hall, UK (1998)Google Scholar
  5. Bird, R., de Moor, O.: Algebra of Programming. Prentice-Hall Inernational Series in Computer Science, vol. 100. Prentice-Hall, Upper Saddle River (1997)zbMATHGoogle Scholar
  6. Cockett, R., Fukushima, T.: About Charity. Technical Report 92/480/18, University of Calgary, June 1992Google Scholar
  7. Cockett, R., Spencer, D.: Strong Categorical Datatypes I. In: Seely, R.A.C., (ed.) International Meeting on Category Theory 1991. Canadian Mathematical Society Conference Proceedings, vol. 13, pp. 141–169 (1991)Google Scholar
  8. Danielsson, N.A., Hughes, J., Jansson, P., Gibbons, J.: Fast and loose reasoning is morally correct. In: Conference Record of the 33rd ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages, POPL 2006, pp. 206–217. ACM, New York (2006)Google Scholar
  9. Fernandes, J.P.: Design, Implementation and Calculation of Circular Programs. PhD thesis, Deparment of Informatics, University of Minho, Portugal (2009)Google Scholar
  10. Fernandes, J.P., Pardo, A., Saraiva, J.: A shortcut fusion rule for circular program calculation. In: Proceedings of the ACM SIGPLAN Haskell Workshop, Haskell 2007, pp. 95–106. ACM Press, New York (2007)Google Scholar
  11. Gibbons, J.: Calculating functional programs. In: Backhouse, R., Crole, R., Gibbons, J. (eds.) Algebraic and Coalgebraic Methods in the Mathematics of Program Construction. LNCS, vol. 2297, pp. 151–203. Springer, Heidelberg (2002).  https://doi.org/10.1007/3-540-47797-7_5CrossRefGoogle Scholar
  12. Gill, A.: Cheap deforestation for non-strict functional languages. PhD thesis, Department of Computing Science, University of Glasgow, UK (1996)Google Scholar
  13. Gill, A., Launchbury, J., Jones, S.L.P.: A short cut to deforestation. In: Conference on Functional Programming Languages and Computer Architecture, pp. 223–232, June 1993Google Scholar
  14. Hughes, J.: Why functional programming matters. Comput. J. 32, 98–107 (1984)CrossRefGoogle Scholar
  15. Kastens, U., Pfahler, P., Jung, M.: The eli system. In: Koskimies, K. (ed.) CC 1998. LNCS, vol. 1383, pp. 294–297. Springer, Heidelberg (1998).  https://doi.org/10.1007/BFb0026439CrossRefGoogle Scholar
  16. Pardo, A.: A calculational approach to recursive programs with effects. PhD thesis, Technische Universität Darmstadt, October 2001Google Scholar
  17. Pardo, A.: Generic Accumulations. In: IFIP WG2.1 Working Conference on Generic Programming, Dagstuhl, Germany, July 2002Google Scholar
  18. Pardo, A., Fernandes, J.P., Saraiva, J.: Shortcut fusion rules for the derivation of circular and higher-order monadic programs. In: Proceedings of the 2009 ACM SIGPLAN Symposium on Partial Evaluation and Program Manipulation, PEPM 2009, pp. 81–90. ACM Press (2009)Google Scholar
  19. Pardo, A., Fernandes, J.P., Saraiva, J.: Shortcut fusion rules for the derivation of circular and higher-order programs. Higher-Order Symb. Comput. 24(1–2), 115–149 (2011). ISSN 1388–3690MathSciNetCrossRefGoogle Scholar
  20. Pardo, A., Fernandes, J.P., Saraiva, J.: Multiple intermediate structure deforestation by shortcut fusion. In: Du Bois, A.R., Trinder, P. (eds.) SBLP 2013. LNCS, vol. 8129, pp. 120–134. Springer, Heidelberg (2013).  https://doi.org/10.1007/978-3-642-40922-6_9CrossRefGoogle Scholar
  21. Pettorossi, A., Skowron, A.: The lambda abstraction strategy for program derivation. In: Fundamenta Informaticae XII, pp. 541–561 (1987)Google Scholar
  22. Jones, S.P. (ed.) Haskell 98 Language and Libraries: The Revised Report. Cambridge University Press (2003). Also in Journal of Functional Programming, 13(1)Google Scholar
  23. Jones, S.P., Hughes, J., Augustsson, L., et al.: Report on the programming language Haskell 98. Technical report, February 1999Google Scholar
  24. Takano, A., Meijer, E.: Shortcut deforestation in calculational form. In: Proceedings of Conference on Functional Programming Languages and Computer Architecture, pp. 306–313. ACM Press (1995)Google Scholar
  25. Voigtländer, J.: Semantics and pragmatics of new shortcut fusion rules. In: Garrigue, J., Hermenegildo, M.V. (eds.) FLOPS 2008. LNCS, vol. 4989, pp. 163–179. Springer, Heidelberg (2008).  https://doi.org/10.1007/978-3-540-78969-7_13CrossRefzbMATHGoogle Scholar
  26. Wadler, P.: Theorems for free! In: 4th International Conference on Functional Programming and Computer Architecture, London (1989)Google Scholar
  27. Wadler, P.: Deforestation: transforming programs to eliminate trees. Theoret. Comput. Sci. 73, 231–248 (1990)MathSciNetCrossRefGoogle Scholar
  28. Waite, W., Kastens, U., Sloane, A.M.: Generating Software from Specifications. Jones and Bartlett Publishers Inc, USA (2007)Google Scholar

Copyright information

© Springer Nature Switzerland AG 2019

Authors and Affiliations

  • João Paulo Fernandes
    • 1
    Email author
  • Jácome Cunha
    • 2
  • João Saraiva
    • 3
  • Alberto Pardo
    • 4
  1. 1.CISUCUniversidade de CoimbraCoimbraPortugal
  2. 2.NOVA LINCSUniversidade do MinhoBragaPortugal
  3. 3.HASLab/INESC TECUniversidade do MinhoBragaPortugal
  4. 4.Universidad de la RepúblicaMontevideoUruguay

Personalised recommendations