Skip to main content
×
×
Home

Manipulating accumulative functions by swapping call-time and return-time computations*

  • AKIMASA MORIHATA (a1), KAZUHIKO KAKEHI (a2), ZHENJIANG HU (a3) and MASATO TAKEICHI (a4)
Abstract

Functional languages are suitable for transformational developments of programs. However, accumulative functions, or in particular tail-recursive functions, are known to be less suitable for manipulation. In this paper, we propose a program transformation named “IO swapping” that swaps call-time and return-time computations. It moves computations in accumulative parameters to results and thereby enables interesting transformations. We demonstrate effectiveness of IO swapping by several applications: deforestation, higher order removal, program inversion, and manipulation of circular programs.

Copyright
References
Hide All
Backhouse, R. C., Jansson, P., Jeuring, J. & Meertens, L. G. L. T. (1999) Generic programming: An introduction. In Advanced Functional Programming, Third International School, Braga, Portugal, Revised Lectures. Lecture Notes in Computer Science, 1608, pp. 28115. Berlin, Germany: Springer-Verlag.
Bird, R. S. (1984) Using circular programs to eliminate multiple traversals of data. Acta Inf. 21, 239250.
Bird, R. S. & Wadler, P. (1989) Introduction to Functional Programming. Saddle River, NJ: Prentice-Hall.
Boiten, E. A. (1992) Improving recursive functions by inverting the order of evaluation. Sci. Comput. Program. 18 (2), 139179.
Boyer, R. S. & Moore, J. S. (1975) Proving theorems about Lisp functions. J. ACM. 22 (1), 129144.
Boyer, R. S., Moore, J. S. & Shostak, R. E. (1976) Primitive recursive program transformations. In Proceedings of POPL'76: Conference Record of the Third ACM Symposium on Principles of Programming Languages, Atlanta, Georgia. Pittsburgh, PA: ACM Press, pp. 171174.
Burstall, R. M. & Darlington, J. (1977) A transformation system for developing recursive programs. J. ACM. 24 (1), 4467.
Chin, W.-N. (1994) Safe fusion of functional expressions II: Further improvements. J. Funct. Program. 4 (4), 515555.
Correnson, L., Duris, É., Parigot, D. & Roussel, G. (1999) Declarative program transformation: A deforestation case-study. In Proceedings of International Conference on Principles and Practice of Declarative Programming (PPDP'99), Paris, France. Lecture Notes in Computer Science, vol. 1702. Berlin, Germany: Springer-Verlag, pp. 360377.
Danvy, O. & Goldberg, M. (2005) There and back again. Fundam. Inform. 66 (4), 397413.
Fernandes, J. P., Pardo, A. & Saraiva, J (2007) A shortcut fusion rule for circular program calculation. In Proceedings of the ACM SIGPLAN Workshop on Haskell (Haskell 2007), Freiburg, Germany. Pittsburgh, PA: ACM, pp. 95106.
Fernandes, J. P. & Saraiva, J. (2007) Tools and libraries to model and manipulate circular programs. In Proceedings of the 2007 ACM SIGPLAN Workshop on Partial Evaluation and Semantics-Based Program Manipulation, Nice, France. Pittsburgh, PA: ACM, pp. 102111.
Fernandes, J. P., Saraiva, J., Seidel, D. & Voigtländer, J. (2011) Strictification of circular programs. In Proceedings of the 2011 ACM SIGPLAN Workshop on Partial Evaluation and Program Manipulation (PEPM 2011), Austin, TX, USA. Pittsburgh, PA: ACM, pp. 131140.
Giesl, J. (2000). Context-moving transformations for function verification. In Proceedings of the 9th International Workshop on Logic Programming Synthesis and Transformation (LOPSTR'99), selected papers. Lecture Notes in Computer Science, vol. 1817. Berlin, Germany: Springer-Verlag, pp. 293312.
Giesl, J., Kühnemann, A. & Voigtländer, J. (2007) Deaccumulation techniques for improving provability. J. Log. Algebr. Program. 71 (2), 79113.
Gill, A. (1996) Cheap Deforestation for Non-Strict Functional Languages. PhD. thesis, Department of Computing Science, Glasgow University, Glasgow, UK.
Gill, A., Launchbury, J. & Peyton, Jones S. (1993) A short cut to deforestation. In Proceedings of FPCA'93 Conference on Functional Programming Languages and Computer Architecture, Copenhagen, Denmark. New York, NY: ACM Press, pp. 223232.
Glück, R. & Kawabe, M. (2005) A method for automatic program inversion based on LR(0) parsing. Fundam. Inform. 66 (4), 367395.
Katsumata, S. & Nishimura, S. (2008) Algebraic fusion of functions with an accumulating parameter and its improvement. J. Funct. Program. 18 (5–6), 781819.
Kühnemann, A. (1998) Benefits of tree transducers for optimizing functional programs. In Proceedings of the 18th Conference on Foundations of Software Technology and Theoretical Computer Science, Chennai, India. Lecture Notes in Computer Science, vol. 1530. Berlin, Germany: Springer-Verlag, pp. 146157.
Kühnemann, A. (1999) Comparison of deforestation techniques for functional programs and for tree transducers. In Proceedings of the 4th Fuji International Symposium on Functional and Logic Programming (FLOPS'99), Tukuba, Japan. Lecture Notes in Computer Science, vol. 1722. Berlin, Germany: Springer-Verlag, pp. 114130.
Kühnemann, A., Glück, R. & Kakehi, K. (2001) Relating accumulative and non-accumulative functional programs. In Proceedings of the 12th International Conference on Rewriting Techniques and Applications (RTA 2001), Utrecht, the Netherlands. Lecture Notes in Computer Science, vol. 2051. Berlin, Germany: Springer-Verlag, pp. 154168.
Matsuda, K., Mu, S.-C., Hu, Z. & Takeichi, M. (2010) A grammar-based approach to invertible programs. In Proceedings of the 19th European Symposium on Programming Languages and Systems (ESOP 2010), held as part of the Joint European Conferences on Theory and Practice of Software (ETAPS 2010), Paphos, Cyprus. Lecture Notes in Computer Science, vol. 6012. Berlin, Germany: Springer-Verlag, pp. 448467.
Meijer, E., Fokkinga, M. M. & Paterson, R. (1991) Functional programming with bananas, lenses, envelopes and barbed wire. In Proceedings of the 5th ACM Conference on Functional Programming Languages and Computer Architecture, Cambridge, MA, USA. Lecture Notes in Computer Science, vol. 523. Berlin, Germany: Springer-Verlag, pp. 124144.
Mogensen, T. Æ. (2006) Report on an implementation of a semi-inverter. In Proceedings of 6th International Andrei Ershov Memorial Conference on Perspectives of Systems Informatics (PSI 2006), Novosibirsk, Russia, revised papers. Lecture Notes in Computer Science, vol. 4378. Berlin, Germany: Springer-Verlag, pp. 322334.
Morihata, A. (2006) Relationship between Arguments and Results of Recursive Functions. Master's thesis, Graduate School of Information Science and Technology, University of Tokyo, Japan.
Morihata, A., Kakehi, K., Hu, Z. & Takeichi, M. (2006) Swapping arguments and results of recursive functions. In Proceedings of the 8th International Conference on Mathematics of Program Construction (MPC 2006), Kuressaare, Estonia. Lecture Notes in Computer Science, vol. 4014. Berlin, Germany: Springer-Verlag, pp. 379396.
Nishimura, S. (2003) Correctness of a higher-order removal transformation through a relational reasoning. In Proceedings of the First Asian Symposium on Programming Languages and Systems (APLAS 2003), Beijing, China. Lecture Notes in Computer Science, vol. 2895. Berlin, Germany: Springer-Verlag, pp. 358375.
Nishimura, S. (2004) Fusion with stacks and accumulating parameters. In Proceedings of the ACM SIGPLAN Symposium on Partial Evaluation and Semantics-Based Program Manipulation (PEPM'04), Verona, Italy. New York, NY: ACM Press, pp. 101112.
Pardo, A., Fernandes, J. P. & Saraiva, J. (2009) 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 Semantics-Based Program Manipulation (PEPM 2009), Savannah, GA, USA. New York, NY: ACM Press, pp. 8190.
Peyton, Jones S. (ed). (2003) Haskell 98 Language and Libraries: The Revised Report. Cambridge, UK: Cambridge University Press.
Roy, P. V. & Haridi, S. (2004) Concepts, Techniques, and Models of Computer Programming. Cambridge, MA: MIT Press.
Svenningsson, J. (2002) Shortcut fusion for accumulating parameters & zip-like functions. In Proceedings of the 7th ACM SIGPLAN International Conference on Functional Programming (ICFP'02), Pittsburgh, Pennsylvania, USA. New York, NY: ACM Press, pp. 124132.
Takano, A. & Meijer, E. (1995) Shortcut deforestation in calculational form. In Proceedings of SIGPLAN-SIGARCH-WG2.8 Conference on Functional Programming Languages and Computer Architecture (conference record of FPCA'95), La Jolla, CA, USA. New York, NY: ACM Press, pp. 306313.
Voigtländer, J. (2004) Using circular programs to deforest in accumulating parameters. Higher-Order Symb. Comput. 17 (1–2), 129163.
Voigtländer, J. & Kühnemann, A. (2004) Composition of functions with accumulating parameters. J. Funct. Program. 14 (3), 317363.
Wadler, P. (1990) Deforestation: Transforming programs to eliminate trees. Theor. Comput. Sci. 73 (2), 231248.
Wand, M. (1980) Continuation-based program transformation strategies. J. ACM. 27 (1), 164180.
Recommend this journal

Email your librarian or administrator to recommend adding this journal to your organisation's collection.

Journal of Functional Programming
  • ISSN: 0956-7968
  • EISSN: 1469-7653
  • URL: /core/journals/journal-of-functional-programming
Please enter your name
Please enter a valid email address
Who would you like to send this to? *
×

Metrics

Full text views

Total number of HTML views: 0
Total number of PDF views: 16 *
Loading metrics...

Abstract views

Total abstract views: 143 *
Loading metrics...

* Views captured on Cambridge Core between September 2016 - 20th August 2018. This data will be updated every 24 hours.

Manipulating accumulative functions by swapping call-time and return-time computations*

  • AKIMASA MORIHATA (a1), KAZUHIKO KAKEHI (a2), ZHENJIANG HU (a3) and MASATO TAKEICHI (a4)
Submit a response

Discussions

No Discussions have been published for this article.

×

Reply to: Submit a response


Your details


Conflicting interests

Do you have any conflicting interests? *