Abstract
Purely functional arrays are notoriously difficult to implement and use efficiently due to the absence of destructive updates and the resultant frequent copying. Deforestation frameworks such as stream fusion achieve signficant improvements here but fail for a number of important operations which can nevertheless benefit from elimination of temporaries. To mitigate this problem, we extend stream fusion with support for in-place execution of array operations. This optimisation, which we call recycling, is easy to implement and can significantly reduce array allocation and copying in purely functional array algorithms.
This is a preview of subscription content, log in via an institution.
Buying options
Tax calculation will be finalised at checkout
Purchases are for personal use only
Learn about institutional subscriptionsPreview
Unable to display preview. Download preview PDF.
References
Wadler, P.: Deforestation: transforming programs to eliminate trees. Theoretical Computer Science (Special issue of selected papers from 2nd European Symposium on Programming) 73(2), 231–248 (1990)
Gill, A., Launchbury, J., Peyton Jones, S.: A short cut to deforestation. In: Conference on Functional Programming Languages and Computer Architecture, pp. 223–232 (1993)
Johann, P.: Short cut fusion: Proved and improved. In: Taha, W. (ed.) SAIG 2001. LNCS, vol. 2196, pp. 47–71. Springer, Heidelberg (2001)
Svenningsson, J.: Shortcut fusion for accumulating parameters & zip-like functions. In: Proceedings of the 7th ACM SIGPLAN International Conference on Functional programming, pp. 124–132. ACM Press, New York (2002)
Chakravarty, M.M.T., Keller, G.: Functional array fusion. In: Leroy, X. (ed.) Proceedings of the Sixth ACM SIGPLAN International Conference on Functional Programming, pp. 205–216. ACM Press, New York (2001)
Chakravarty, M.M.T., Leshchinskiy, R., Peyton Jones, S., Keller, G., Marlow, S.: Data Parallel Haskell: a status report. In: DAMP 2007: Proceedings of the 2007 workshop on Declarative aspects of multicore programming, pp. 10–18. ACM, New York (2007)
Coutts, D., Leshchinskiy, R., Stewart, D.: Stream fusion: from lists to streams to nothing at all. In: Proceedings of the 2007 ACM SIGPLAN International Conference on Functional programming, pp. 315–326. ACM Press, New York (2007)
Coutts, D., Stewart, D., Leshchinskiy, R.: Rewriting Haskell strings. In: Hanus, M. (ed.) PADL 2007. LNCS, vol. 4354, pp. 50–64. Springer, Heidelberg (2006)
Bloss, A.: Update analysis and the efficient implementation of functional aggregates. In: Proceedings of the 4th international conference on Functional programming languages and computer architecture, pp. 26–38. ACM, New York (1989)
Odersky, M.: How to make destructive updates less destructive. In: Proc. 18th ACM Symp. on Principles of Programming Languages, pp. 25–36. ACM Press, New York (1991)
Sastry, A.V.S., Clinger, W., Ariola, Z.: Order-of-evaluation analysis for destructive updates in strict functional languages with flat aggregates. In: Conference on Functional Programming Languages and Computer Architecture, pp. 266–275. ACM Press, New York (1993)
Wadler, P.: Linear types can change the world. In: Programming Concepts and Methods, North, 347–359 (1990)
Launchbury, J., Peyton Jones, S.L.: Lazy functional state threads. In: SIGPLAN Conference on Programming Language Design and Implementation, pp. 24–35 (1994)
Peyton Jones, S.: Call-pattern specialisation for Haskell programs. In: Proceedings of the 2007 ACM SIGPLAN International Conference on Functional programming, pp. 327–337. ACM, New York (2007)
Peyton Jones, S., Santos, A.L.M.: A transformation-based optimiser for Haskell. Sci. Comput. Program. 32(1-3), 3–47 (1998)
Peyton Jones, S., Tolmach, A., Hoare, T.: Playing by the rules: rewriting as a practical optimisation technique in GHC. In: Hinze, R. (ed.) 2001 Haskell Workshop. ACM, New York (2001)
Leiserson, C.E., Maggs, B.M.: Communication-efficient parallel algorithms for distributed random-access machines. Algorithmica 3, 53–77 (1988)
Author information
Authors and Affiliations
Editor information
Editors and Affiliations
Rights and permissions
Copyright information
© 2008 Springer-Verlag Berlin Heidelberg
About this paper
Cite this paper
Leshchinskiy, R. (2008). Recycle Your Arrays! . In: Gill, A., Swift, T. (eds) Practical Aspects of Declarative Languages. PADL 2009. Lecture Notes in Computer Science, vol 5418. Springer, Berlin, Heidelberg. https://doi.org/10.1007/978-3-540-92995-6_15
Download citation
DOI: https://doi.org/10.1007/978-3-540-92995-6_15
Publisher Name: Springer, Berlin, Heidelberg
Print ISBN: 978-3-540-92994-9
Online ISBN: 978-3-540-92995-6
eBook Packages: Computer ScienceComputer Science (R0)