Skip to main content
Log in

Warm fusion in Stratego: A case study in generation of program transformation systems

  • Published:
Annals of Mathematics and Artificial Intelligence Aims and scope Submit manuscript

Abstract

Stratego is a domain-specific language for the specification of program transformation systems. The design of Stratego is based on the paradigm of rewriting strategies: user-definable programs in a little language of strategy operators determine where and in what order transformation rules are (automatically) applied to a program. The separation of rules and strategies supports modularity of specifications. Stratego also provides generic features for specification of program traversals.

In this paper we present a case study of Stratego as applied to a non-trivial problem in program transformation. We demonstrate the use of Stratego in eliminating intermediate data structures from (also known as deforesting) functional programs via the warm fusion algorithm of Launchbury and Sheard. This algorithm has been specified in Stratego and embedded in a fully automatic transformation system for kernel Haskell. The entire system consists of about 2600 lines of specification code, which breaks down into 1850 lines for a general framework for Haskell transformation and 750 lines devoted to a highly modular, easily extensible specification of the warm fusion transformer itself. Its successful design and construction provides further evidence that programs generated from Stratego specifications are suitable for integration into real systems, and that rewriting strategies are a good paradigm for the implementation of such systems.

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

Access this article

Price excludes VAT (USA)
Tax calculation will be finalised during checkout.

Instant access to the full article PDF.

Similar content being viewed by others

References

  1. A.W. Appel, Compiling with Continuations(Cambridge University Press, 1992).

  2. R.M. Burstall and J. Darlington, A transformational system for developing recursive programs, J. of the ACM 24(1) (1977) 44-67.

    Article  MATH  MathSciNet  Google Scholar 

  3. W.N. Chin, Safe fusion of functional expressions, ACMLisp Pointers 5(1) (1992) 11-20, Proceedings of the 1992 ACM Conference on Lisp and Functional Programming.

    Google Scholar 

  4. M. de Jonge, A pretty-printer for every occasion, in: Proceedings of the 2nd International Symposium on Constructing Software Engineering Tools (CoSET2000), eds. I. Ferguson, J. Gray and L. Scott, Limerick, Ireland (June 2000); also: Technical Report, University of Wollongong, Australia.

    Google Scholar 

  5. M. Fokkinga, Law and order in algorithmics, Ph.D. thesis, Twente University (1992).

  6. P. Fradet and D. Le Métayer, Compilation of functional languages by program transformation, ACM Trans. Programming Languages Syst. 13(1) (1991) 21-51.

    Article  Google Scholar 

  7. A.J. Gill, Cheap deforestation for non-strict functional languages, Ph.D. thesis, University of Glasgow (January 1996).

  8. A. Gill, J. Launchbury and S.L. Peyton Jones, A short cut to deforestation, in: Functional Programming Languages and Computer Architecture (FPCA'93), ed. Arvind (ACMPress, 1993) pp. 223-232.

  9. T. Hagino, A categorical programming language, Ph.D. thesis, University of Edinburgh (1987).

  10. Z. Hu, H. Iwasaki and M. Takeichi, Deriving structural hylomorphisms from recursive definitions, ACM SIGPLAN Notices 31(6) (1996) 73-82, Proceedings of the International Conference on Functional Programming (ICFP'96), Philadelphia.

    Google Scholar 

  11. P. Johann, An implementation of warm fusion, available at ftp://ftp.cse.ogi.edu/pub/ pacsoft/wf/ (1997).

  12. P. Johann, Short cut fusion is correct, Technical report, Bates College, Lewiston, Maine, USA (2000).

    Google Scholar 

  13. P. Johann and E. Visser, Warm fusion in Stratego: A case study in the generation of program transformation systems, Technical report, Institute of Information and Computing Sciences, Universiteit Utrecht, Utrecht, The Netherlands (2000).

    Google Scholar 

  14. J. Launchbury and T. Sheard, Warm fusion: Deriving build-catas from recursive definitions, in: Functional Programming Languages and Computer Architecture (FPCA'95), ed. S.L. Peyton Jones (ACM Press, 1995) pp. 314-323.

  15. B. Luttik and E. Visser, Specification of rewriting strategies, in: 2nd International Workshop on the Theory and Practice of Algebraic Specifications (ASF+SDF'97), ed. M.P.A. Sellink, ElectronicWorkshops in Computing, Berlin, November 1997 (Springer, Berlin, 1997).

    Google Scholar 

  16. G. Malcolm, Homomorphisms and promotability, in: Mathematics of Program Construction, Lecture Notes in Computer Science, Vol. 375 (Springer, Berlin, 1989) pp. 335-347.

    Google Scholar 

  17. G.J. Malcolm, Data structures and program transformation, Sci. Comput. Programming 14 (1990) 255-279.

    Article  MATH  MathSciNet  Google Scholar 

  18. E. Meijer, M. Fokkinga and R. Paterson, Functional programming with bananas, lenses, envelopes and barbed wire, in: Functional Programming and Computer Architecture (FPCA'91), ed. R.J.M. Hughes, Lecture Notes in Computer Science, Vol. 523 (Springer, Berlin, 1991) pp. 124-144.

    Google Scholar 

  19. L. Németh, Catamorphism based program transformation for non-strict functional langauges, Draft, Ph.D. thesis, University of Glasgow (2000).

  20. W. Partain, The nofib benchmark suite of Haskell programs, in: Functional Programming, eds. J. Launchbury and P.M. Sansom (Springer, Berlin, 1992) pp. 195-202.

    Google Scholar 

  21. S. Peyton Jones, J. Hughes et al., Report of the programming language Haskell98 a non-strict, purely functional language (February 1999).

  22. S.L. Peyton Jones and J. Launchbury, Unboxed values as first class citizens in a non-strict functional language, in: Functional Programming and Computer Architecture (FPCA'91), ed. R.J.M. Hughes, Lecture Notes in Computer Science, Vol. 523 (Springer, Berlin, 1991) pp. 636-666.

    Google Scholar 

  23. S.L. Peyton Jones and A.L.M. Santos, A transformation-based optimiser for Haskell, Sci. Comput. Programming 32(1-3) (1998) 3-47.

    Article  Google Scholar 

  24. T. Sheard and L. Fegaras, A fold for all seasons, in: Functional Programming and Computer Architecture (FPCA'93), ed. Arvind, Copenhagen, Denmark (ACM Press, 1993) pp. 233-242.

  25. A. Takano and E. Meijer, Shortcut deforestation in calculational form, in: Functional Programming and Computer Architecture (FPCA'95), ed. S.L. Peyton-Jones, San Diego, CA (June 1995).

  26. A. Tolmach and D. Oliva, From ML to Ada: Strongly-typed language interoperability via source translation, J. Funct. Programming 8(4) (1998) 367-412.

    Article  MATH  Google Scholar 

  27. V. Turchin, The concept of a supercompiler, ACM Trans. Programming Languages Syst. 8(3) (1986) 292-326.

    Article  MATH  MathSciNet  Google Scholar 

  28. M.G.J. van den Brand, H.A. de Jong, P. Klint and P.A. Olivier, Efficient annotated terms, Software Practice Exper. 30 (2000) 259-291.

    Article  Google Scholar 

  29. M.G.J. van den Brand and E. Visser, Generation of formatters for context-free languages, ACMTrans. Software Engrg. Methodol. 5(1) (1996) 1-41.

    Article  Google Scholar 

  30. E. Visser, Syntax definition for language prototyping, Ph.D. thesis, University of Amsterdam (September 1997).

  31. E. Visser, Strategic pattern matching, in: Rewriting Techniques and Applications (RTA'99), eds. P. Narendran and M. Rusinowitch, Lecture Notes in Computer Science, Vol. 1631, Trento, Italy, July 1999 (Springer, Berlin, 1999) pp. 30-44.

    Google Scholar 

  32. E. Visser, The Stratego Library, Institute of Information and Computing Sciences, Universiteit Utrecht, Utrecht, The Netherlands (1999).

    Google Scholar 

  33. E. Visser, Language independent traversals for program transformation, in: Workshop on Generic Programming (WGP2000), ed. J. Jeuring, Ponte de Lima, Portugal, July 6 (2000); also: Technical Report UU-CS-2000-19, Universiteit Utrecht.

  34. E. Visser and Zine-el-Abidine Benaissa, A core language for rewriting, in: Proceedings of the Second International Workshop on Rewriting Logic and its Applications (WRLA'98), eds. C. Kirchner and H. Kirchner, Electronic Notes in Theoretical Computer Science, Vol. 15 (1998).

  35. E. Visser, Zine-el-Abidine Benaissa and A. Tolmach, Building program optimizers with rewriting strategies, ACM SIGPLAN Notices 34(1) (1999) 13-26, Proceedings of the International Conference on Functional Programming (ICFP'98).

    Google Scholar 

  36. P. Wadler, Deforestation: Transforming programs to eliminate trees, Theor. Comput. Sci. 73 (1990) 231-248.

    Article  MATH  MathSciNet  Google Scholar 

  37. www.stratego-language.org.

Download references

Author information

Authors and Affiliations

Authors

Rights and permissions

Reprints and permissions

About this article

Cite this article

Johann, P., Visser, E. Warm fusion in Stratego: A case study in generation of program transformation systems. Annals of Mathematics and Artificial Intelligence 29, 1–34 (2000). https://doi.org/10.1023/A:1018956702672

Download citation

  • Issue Date:

  • DOI: https://doi.org/10.1023/A:1018956702672

Keywords

Navigation