Theory and Practice of Fusion

  • Ralf Hinze
  • Thomas Harper
  • Daniel W. H. James
Part of the Lecture Notes in Computer Science book series (LNCS, volume 6647)


There are a number of approaches for eliminating intermediate data structures in functional programs—this elimination is commonly known as fusion. Existing fusion strategies are built upon various, but related, recursion schemes, such as folds and unfolds. We use the concept of recursive coalgebras as a unifying theoretical and notational framework to explore the foundations of these fusion techniques. We first introduce the calculational properties of recursive coalgebras and demonstrate their use with proofs and derivations in a calculational style, then provide an overview of fusion techniques by bringing them together in this setting. We also showcase these developments with examples in Haskell.


Natural Transformation Fusion Technique Proof Obligation Recursion Scheme Polymorphic Type 
These keywords were added by machine and not by the authors. This process is experimental and the keywords may be updated as the learning algorithm improves.


Unable to display preview. Download preview PDF.

Unable to display preview. Download preview PDF.


  1. 1.
    Capretta, V.: General recursion via coinductive types. Logical Methods in Computer Science 1(2), 1–28 (2005)MathSciNetCrossRefzbMATHGoogle Scholar
  2. 2.
    Capretta, V., Uustalu, T., Vene, V.: Recursive coalgebras from comonads. Information and Computation 204(4), 437–468 (2006)MathSciNetCrossRefzbMATHGoogle Scholar
  3. 3.
    Chin, W.N.: Safe Fusion of Functional Expressions. In: LISP and functional programming, pp. 11–20 (1992)Google Scholar
  4. 4.
    Church, A.: The calculi of lambda-conversion. Annals of Mathematics Studies, vol. 6. Princeton University Press, Princeton (1941)zbMATHGoogle Scholar
  5. 5.
    Coutts, D., Leshchinskiy, R., Stewart, D.: Stream Fusion: From Lists to Streams to Nothing At All. In: ICFP 2007, pp. 315–326 (2007)Google Scholar
  6. 6.
    Fegaras, L., Sheard, T., Zhou, T.: Improving Programs which Recurse over Multiple Inductive Structures. In: PEPM 1994 (June 1994)Google Scholar
  7. 7.
    Fokkinga, M.M., Meijer, E.: Program calculation properties of continuous algebras. Technical Report CS-R9104. CWI, Amsterdam (January 1991)Google Scholar
  8. 8.
    Freyd, P.J.: Remarks on algebraically compact categories. In: Fourman, M.P., Johnstone, P.T., Pitts, A.M. (eds.) Applications of Categories in Computer Science. LMS Lecture Note Series, vol. 177, pp. 95–106. Cambridge University Press, Cambridge (1992)CrossRefGoogle Scholar
  9. 9.
    Gill, A., Launchbury, J., Peyton Jones, S.L.: A Short Cut to Deforestation. Functional programming languages and computer architecture, 223–232 (1993)Google Scholar
  10. 10.
    Hinze, R., Harper, T., James, D.W.H.: Theory and Practice of Fusion. Tech. Rep. CS-RR-11-01. Oxford University Computing Laboratory (2011)Google Scholar
  11. 11.
    Hu, Z., Iwasaki, H., Takeichi, M.: An Extension of The Acid Rain Theorem. Functional and Logic Programming, 91–105 (1996)Google Scholar
  12. 12.
    Johann, P., Ghani, N.: Initial algebra semantics is enough! In: Della Rocca, S.R. (ed.) TLCA 2007. LNCS, vol. 4583, pp. 207–222. Springer, Heidelberg (2007)CrossRefGoogle Scholar
  13. 13.
    Lambek, J.: A fixpoint theorem for complete categories. Math. Zeitschr. 103, 151–161 (1968)MathSciNetCrossRefzbMATHGoogle Scholar
  14. 14.
    Mac Lane, S.: Categories for the Working Mathematician, 2nd edn. Graduate Texts in Mathematics. Springer, Berlin (1998)zbMATHGoogle Scholar
  15. 15.
    Meijer, E., Fokkinga, M., Paterson, R.: Functional programming with bananas, lenses, envelopes and barbed wire. In: Hughes, J. (ed.) FPCA 1991. LNCS, vol. 523, pp. 124–144. Springer, Heidelberg (1991)CrossRefGoogle Scholar
  16. 16.
    Reynolds, J.C.: Types, abstraction and parametric polymorphism. In: Mason, R.E.A. (ed.) Information Processing 1983, pp. 513–523. North-Holland, Amsterdam (1983)Google Scholar
  17. 17.
    Sheard, T., Fegaras, L.: A Fold for All Seasons. Functional programming languages and computer architecture, 233–242 (1993)Google Scholar
  18. 18.
    Svenningsson, J.: Shortcut fusion for Accumulating Parameters & Zip-like Functions. In: ICFP 2002, pp. 124–132 (2002)Google Scholar
  19. 19.
    Takano, A., Meijer, E.: Shortcut deforestation in calculational form. Functional programming languages and computer architecture, 306–313 (1995)Google Scholar
  20. 20.
    Voigtländer, J.: Proving correctness via free theorems: the case of the destroy/build-rule. Partial Eval. and Semantics-Based Prog. Manip. 13–20 (2008)Google Scholar
  21. 21.
    Wadler, P.: Theorems for free! In: FPCA, pp. 347–359 (1989)Google Scholar
  22. 22.
    Wadler, P.: Deforestation: transforming programs to eliminate trees. Theoretical Computer Science 73(2), 231–248 (1990)MathSciNetCrossRefzbMATHGoogle Scholar
  23. 23.
    Wang, M., Gibbons, J., Matsuda, K., Hu, Z.: Gradual refinement: Blending pattern matching with data abstraction. In: Bolduc, C., Desharnais, J., Ktari, B. (eds.) MPC 2010. LNCS, vol. 6120, pp. 397–425. Springer, Heidelberg (2010)CrossRefGoogle Scholar

Copyright information

© Springer-Verlag Berlin Heidelberg 2011

Authors and Affiliations

  • Ralf Hinze
    • 1
  • Thomas Harper
    • 1
  • Daniel W. H. James
    • 1
  1. 1.Computing LaboratoryUniversity of OxfordOxfordEngland

Personalised recommendations