Advertisement

Streaming Representation-Changers

  • Jeremy Gibbons
Conference paper
Part of the Lecture Notes in Computer Science book series (LNCS, volume 3125)

Abstract

Unfolds generate data structures, and folds consume them. A hylomorphism is a fold after an unfold, generating then consuming a virtual data structure. A metamorphism is the opposite composition, an unfold after a fold; typically, it will convert from one data representation to another. In general, metamorphisms are less interesting than hylomorphisms: there is no automatic fusion to deforest the intermediate virtual data structure. However, under certain conditions fusion is possible: some of the work of the unfold can be done before all of the work of the fold is complete. This permits streaming metamorphisms, and among other things allows conversion of infinite data representations. We present a theory of metamorphisms and outline some examples.

Keywords

Continue Fraction Functional Programming Binary Search Tree Arithmetic Code Empty List 
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.

Preview

Unable to display preview. Download preview PDF.

Unable to display preview. Download preview PDF.

References

  1. 1.
    Augusteijn, L.: Sorting morphisms. In: Swierstra, S.D., Oliveira, J.N. (eds.) AFP 1998. LNCS, vol. 1608, pp. 1–27. Springer, Heidelberg (1999)CrossRefGoogle Scholar
  2. 2.
    Beeler, M., Gosper, R.W., Schroeppel, R.: Hakmem. AIM 239, MIT (February 1972)Google Scholar
  3. 3.
    Bird, R., de Moor, O.: The Algebra of Programming. Prentice-Hall, Englewood Cliffs (1996)Google Scholar
  4. 4.
    Bird, R., Gibbons, J.: Arithmetic coding with folds and unfolds. In: Jeuring, J., Jones, S.L.P. (eds.) AFP 2002. LNCS, vol. 2638, Springer, Heidelberg (2003)CrossRefGoogle Scholar
  5. 5.
    Bird, R.S.: Introduction to Functional Programming Using Haskell. Prentice-Hall, Englewood Cliffs (1998)Google Scholar
  6. 6.
    Bird, R.S., Wadler, P.L.: An Introduction to Functional Programming. Prentice-Hall, Englewood Cliffs (1988)Google Scholar
  7. 7.
    Boiten, E.: The many disguises of accumulation. Technical Report 91-26, Department of Informatics, University of Nijmegen (December 1991) Google Scholar
  8. 8.
    Gamma, E., Helm, R., Johnson, R., Vlissides, J.: Design Patterns: Elements of Reusable Object-Oriented Software. Addison-Wesley, Reading (1995)Google Scholar
  9. 9.
    Gibbons, J.: Algebras for Tree Algorithms. D.Phil. thesis, Programming Research Group, Oxford University (1991), Available as Technical Monograph PRG-94. ISBN 0-902928-72-4 Google Scholar
  10. 10.
    Gibbons, J.: Polytypic downwards accumulations. In: Jeuring, J. (ed.) MPC 1998. LNCS, vol. 1422, Springer, Heidelberg (1998)CrossRefGoogle Scholar
  11. 11.
    Gibbons, J.: Generic downwards accumulations. Science of Computer Programming 37, 37–65 (2000)zbMATHCrossRefMathSciNetGoogle Scholar
  12. 12.
    Gibbons, J.: Chapter 5 Calculating Functional Programs. In: Blackhouse, R., Crole, R.L., Gibbons, J. (eds.) Algebraic and Coalgebraic Methods in the Mathematics of Program Construction. LNCS, vol. 2297, pp. 149–203. Springer, Heidelberg (2002)CrossRefGoogle Scholar
  13. 13.
    Gibbons, J.: Origami programming. In: Gibbons, J., de Moor, O. (eds.) The Fun of Programming, Cornerstones in Computing, Palgrave (2003)Google Scholar
  14. 14.
    Gibbons, J.: An unbounded spigot algorithm for the digits of π. Draft (November 2003) Google Scholar
  15. 15.
    Gibbons, J., Hutton, G.: Proof methods for corecursive programs (submitted for publication) (March 2004)Google Scholar
  16. 16.
    Gibbons, J., Jones, G.: The under-appreciated unfold. In: Proceedings of the Third ACM SIGPLAN International Conference on Functional Programming, Baltimore, Maryland, September 1998, pp. 273–279 (1998)Google Scholar
  17. 17.
    Gosper, B.: Continued fraction arithmetic. Unpublished manuscript (1981) Google Scholar
  18. 18.
    Hagino, T.: A typed lambda calculus with categorical type constructors. In: Pitt, D.H., Rydeheard, D.E., Poigné, A. (eds.) Category Theory and Computer Science. LNCS, vol. 283, pp. 140–157. Springer, Heidelberg (1987)Google Scholar
  19. 19.
    Hoare, C.A.R.: Quicksort. Computer Journal 5, 10–15 (1962) Google Scholar
  20. 20.
    Hughes, J.: Why functional programming matters. Computer Journal 32(2), 98–107 (1989), Also in [36]Google Scholar
  21. 21.
    Hutton, G., Meijer, E.: Back to basics: Deriving representation changers functionally. Journal of Functional Programming 6(1), 181–188 (1996)CrossRefGoogle Scholar
  22. 22.
    Jackson, M.A.: Principles of Program Design. Academic Press, London (1975)Google Scholar
  23. 23.
    Jacobs, B.: Mongruences and cofree coalgebras. In: Alagar, V.S., Nivat, M. (eds.) AMAST 1995. LNCS, vol. 936, Springer, Heidelberg (1995)Google Scholar
  24. 24.
    Jones, S.P.: Arbitrary precision arithmetic using continued fractions. INDRA Working Paper 1530, Dept of CS, University College, London (January 1984) Google Scholar
  25. 25.
    Jones, S.P.: The Haskell 98 Language and Libraries: The Revised Report. Cambridge University Press, Cambridge (2003)Google Scholar
  26. 26.
    Lester, D.: Vuillemin’s exact real arithmetic. In: Heldal, R., Holst, C.K., Wadler, P. (eds.) Glasgow Functional Programming Workshop, pp. 225–238 (1991)Google Scholar
  27. 27.
    Lester, D.: Effective continued fractions. In: Proceedings of the Fifteenth IEEE Arithmetic Conference (2001)Google Scholar
  28. 28.
    Malcolm, G.: Data structures and program transformation. Science of Computer Programming 14, 255–279 (1990)zbMATHCrossRefMathSciNetGoogle Scholar
  29. 29.
    Meertens, L.: Paramorphisms. Formal Aspects of Computing 4(5), 413–424 (1992)zbMATHCrossRefGoogle Scholar
  30. 30.
    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)Google Scholar
  31. 31.
    Pardo, A.: Generic accumulations. In: Gibbons, J., Jeuring, J. (eds.) Generic Programming, pp. 49–78. Kluwer Academic Publishers, Dordrecht (2003), Proceedings of the IFIP TC2Working Conference on Generic Programming, Schloß Dagstuhl (July 2002) ISBN 1-4020-7374-7Google Scholar
  32. 32.
    Potts, P.J.: Exact Real Arithmetic using Möbius Transformations. PhD thesis, Imperial College, London (July 1998) Google Scholar
  33. 33.
    Rabinowitz, S., Wagon, S.: A spigot algorithm for the digits of π. American Mathematical Monthly 102(3), 195–203 (1995)zbMATHCrossRefMathSciNetGoogle Scholar
  34. 34.
    Reynolds, J.C.: Definitional interpreters for higher-order programming languages. Higher Order and Symbolic Computing 11(4), 363–397 (1998), Reprinted from the Proceedings of the 25th ACM National Conference (1972)Google Scholar
  35. 35.
    Swierstra, D., de Moor, O.: Virtual data structures. In: Möller, B., Schuman, S., Partsch, H. (eds.) Formal Program Development. LNCS, vol. 755, pp. 355–371. Springer, Heidelberg (1993)Google Scholar
  36. 36.
    Turner, D.A. (ed.): Research Topics in Functional Programming. University of Texas at Austin, Addison-Wesley (1990) Google Scholar
  37. 37.
    Vene, V., Uustalu, T.: Functional programming with apomorphisms (corecursion). In: Proceedings of the Estonian Academy of Sciences: Physics, Mathematics, vol. 47(3), pp. 147–161 (1998) 9th Nordic Workshop on Programming TheoryGoogle Scholar
  38. 38.
    Vuillemin, J.: Exact real arithmetic with continued fractions. IEEE Transactions on Computers 39(8), 1087–1105 (1990)CrossRefMathSciNetGoogle Scholar
  39. 39.
    Wadler, P.: Deforestation: Transforming programs to eliminate trees. Theoretical Computer Science 73, 231–248 (1990)zbMATHCrossRefMathSciNetGoogle Scholar
  40. 40.
    Witten, I.H., Neal, R.M., Cleary, J.G.: Arithmetic coding for data compression. Communications of the ACM 30(6), 520–540 (1987)CrossRefGoogle Scholar

Copyright information

© Springer-Verlag Berlin Heidelberg 2004

Authors and Affiliations

  • Jeremy Gibbons
    • 1
  1. 1.Computing LaboratoryUniversity of Oxford 

Personalised recommendations