Abstract
We show how programming pearls can be systematically derived via fusion, followed by tupling transformations. By focusing on the elimination of intermediate data structures (fusion) followed by the elimination of redundant calls (tupling), we systematically realise both space and time efficient algorithms from naive specifications. We illustrate our approach using a well-known maximum segment sum (MSS) problem, and a less-known maximum segment product (MSP) problem. While the two problems share similar specifications, their optimised codes are significantly different. This divergence in the transformed codes do not pose any difficulty. By relying on modular techniques, we are able to systematically reuse both code and transformation in our derivation.
Access this chapter
Tax calculation will be finalised at checkout
Purchases are for personal use only
Preview
Unable to display preview. Download preview PDF.
References
R.M. Burstall and J. Darlington. A transformation system for developing recursive programs. Journal of ACM, 24(1):44–67, January 1977.
Jon Bentley. Programming Pearls. Addison-Wesley, 1986.
Richard S. Bird. The promotion and accumulation strategies in transformational programming. ACM Trans. on Programming Languages and Systems, 6(4):487–504, October 1984.
Richard S. Bird. Lectures on Constructive Functional Programming. Springer-Verlag, 1988.
Richard S. Bird. Lecture notes on theory of lists. In STOP Summer School on Constructive Algorithmics, Abeland, pages 1–25, 9 1989.
Wei-Ngan Chin. Safe fusion of functional expressions. In 7th ACM LISP and Functional Programming Conference, pages 11–20, San Francisco, California, June 1992. ACM Press.
Wei-Ngan Chin. Towards an automated tupling strategy. In ACM SIGPLAN Symposium on Partial Evaluation and Semantics-Based Program Manipulation, pages 119–132, Copenhagen, Denmark, June 1993. ACM Press.
Wei-Ngan Chin. Safe fusion of functional expressions II: Further improvements. Journal of Functional Programming, 4(4):515–555, October 1994.
Manuel MT Chakravarty and Gabriele Keller. Functional array fusion. In ACM Intl. Conference on Functional Programming, pages 205–216, Florence, Italy, September 2001. ACM Press.
W.N. Chin and A. Takano. Deriving laws by program specialization. Technical report, Hitachi Advanced Research Laboratory, July 1997.
M. Fokkinga. Tupling and mutumorphisms. Squiggolist, 1(4), 1989.
M. Fokkinga. Law and Order in Algorithmics. Ph.D thesis, Dept. INF, University of Twente, The Netherlands, 1992.
A. Gill, J. Launchbury, and S. Peyton-Jones. A short-cut to deforestation. In 6th ACM Conference on Functional Programming Languages and Computer Architecture, Copenhagen, Denmark, June 1993. ACM Press.
Z. Hu, H. Iwasaki, and M. Takeichi. Deriving structural hylomorphisms from recursive definitions. In ACM SIGPLAN International Conference on Functional Programming, pages 73–82, Philadelphia, Pennsylvannia, May 1996. ACM Press.
Z. Hu, H. Iwasaki, and M. Takeichi. Calculating accumulations. New Generation Computing, 17(2):153–173, 1999.
Z. Hu, H. Iwasaki, M. Takeichi, and A. Takano. Tupling calculation eliminates multiple traversals. In 2nd ACM SIGPLAN International Conference on Functional Programming, pages 164–175, Amsterdam, Netherlands, June 1997. ACM Press.
Z. Hu, M. Takeichi, and W.N. Chin. Parallelization in calculational forms. In 25th Annual ACM Symposium on Principles of Programming Languages, pages 316–328, San Diego, California, January 1998. ACM Press.
J. Jeuring. Theories for Algorithm Calculation. Ph.D thesis, Faculty of Science, Utrecht University, 1993.
S. Peyton Jones and J. Hughes, editors. Haskell 98: A Non-strict, Purely Functional Language. Available online: http://www.haskell.org, February 1999.
T. Sheard and L. Fegaras. A fold for all seasons. In 6th ACM Conference on Functional programming Languages and Computer Architecture, Copenhagen, Denmark, June 1993. ACM Press.
M.H. Sørensen, R. Glück, and Jones N.D. Towards unifying deforestation, supercompilation, partial evaluation and generalised partial computation. In European Symposium on Programming (LNCS 788), Edinburgh, April 1994.
Douglas R. Smith. KIDS-a semi-automatic program development system. Technical report, Kestrel Institute, October 1989.
H. Seidl and M.H. Sørensen. Constraints to stop higher-order deforestation. In 24th ACM Symposium on Principles of Programming Languages, Paris, France, January 1997. ACM Press.
M. Takeichi and Z. Hu. Calculation carrying programs: How to code program transformations (invited paper). In International Sumposium on Principles of Software Evolution (ISPSE 2000), Kanazawa, Japan, November 2000. IEEE Press.
A. Takano and E. Meijer. Shortcut deforestation in calculational form. In ACM Conference on Functional Programming and Computer Architecture, pages 306–313, San Diego, California, June 1995. ACM Press.
Phil Wadler. Deforestation: Transforming programs to eliminate trees. In European Symposium on Programming, Nancy, France, (LNCS, vol 300, pp. 344–358), March 1988.
T. Yokoyama, Z. Hu, and M. Takeichi. Yicho: A system for programming program calculations. Technical Report METR 2002-07, Department of Mathematical Engineering, University of Tokyo, June 2002. submitted for publication.
Author information
Authors and Affiliations
Editor information
Editors and Affiliations
Rights and permissions
Copyright information
© 2002 Springer-Verlag Berlin Heidelberg
About this paper
Cite this paper
Chin, WN., Hu, Z. (2002). Towards a Modular Program Derivation via Fusion and Tupling. In: Batory, D., Consel, C., Taha, W. (eds) Generative Programming and Component Engineering. GPCE 2002. Lecture Notes in Computer Science, vol 2487. Springer, Berlin, Heidelberg. https://doi.org/10.1007/3-540-45821-2_9
Download citation
DOI: https://doi.org/10.1007/3-540-45821-2_9
Published:
Publisher Name: Springer, Berlin, Heidelberg
Print ISBN: 978-3-540-44284-4
Online ISBN: 978-3-540-45821-0
eBook Packages: Springer Book Archive