skip to main content
article

Concatenate, reverse and map vanish for free

Published:17 September 2002Publication History
Skip Abstract Section

Abstract

We introduce a new transformation method to eliminate intermediate data structures occurring in functional programs due to repeated list concatenations and other data manipulations (additionally exemplified with list reversal and mapping of functions over lists).The general idea is to uniformly abstract from data constructors and manipulating operations by means of rank-2 polymorphic combinators that exploit algebraic properties of these operations to provide an optimized implementation. The correctness of transformations is proved by using the free theorems derivable from parametric polymorphic types.

References

  1. http://wwwtcs.inf.tu-dresden.de/~voigt/Vanish.lhs.]]Google ScholarGoogle Scholar
  2. The Haskell 98 Report. http://haskell.org/onlinereport.]]Google ScholarGoogle Scholar
  3. E. Albert, C. Ferri, F. Steiner, and G. Vidal. Improving functional logic programs by difference-lists. In Advances in Computing Science, Penang, Malaysia, Proceedings, volume 1961 of LNCS, pages 237--254. Springer-Verlag, 2000.]] Google ScholarGoogle ScholarDigital LibraryDigital Library
  4. R. Bird. The promotion and accumulation strategies in transformational programming. ACM Trans. on Prog. Lang. and Systems, 6:487--504, 1984. Addendum Ibid., 7:490--492, 1985.]] Google ScholarGoogle ScholarDigital LibraryDigital Library
  5. E. Boiten. The many disguises of accumulation. Technical Report 91-26, Dept. of Informatics, University of Nijmegen, 1991.]]Google ScholarGoogle Scholar
  6. O. Chitil. Type inference builds a short cut to deforestation. In International Conference on Functional Programming, Paris, France, Proceedings, pages 249--260. ACM Press, 1999.]] Google ScholarGoogle ScholarDigital LibraryDigital Library
  7. O. Chitil. Type-Inference Based Deforestation of Functional Programs. PhD thesis, RWTH Aachen, 2000.]]Google ScholarGoogle Scholar
  8. O. Chitil. Compositional explanation of types and algorithmic debugging of type errors. In International Conference on Functional Programming, Florence, Italy, Proceedings, pages 193--204. ACM Press, 2001.]] Google ScholarGoogle ScholarDigital LibraryDigital Library
  9. A. Gill. Cheap Deforestation for Non-strict Functional Languages. PhD thesis, University of Glasgow, 1996.]]Google ScholarGoogle Scholar
  10. A. Gill, J. Launchbury, and S. Peyton Jones. A short cut to deforestation. In Functional Programming Languages and Computer Architecture, Copenhagen, Denmark, Proceedings, pages 223--232. ACM Press, 1993.]] Google ScholarGoogle ScholarDigital LibraryDigital Library
  11. Z. Hu, H. Iwasaki, and M. Takeichi. Calculating accumulations. New Generation Computing, 17:153--173, 1999.]] Google ScholarGoogle ScholarDigital LibraryDigital Library
  12. J. Hughes. A novel representation of lists and its application to the function "reverse". Information Processing Letters, 22:141--144, 1986.]] Google ScholarGoogle ScholarDigital LibraryDigital Library
  13. J. Hughes. The design of a pretty-printing library. In Advanced Functional Programming, volume 925 of LNCS, pages 53--96. Springer-Verlag, 1995.]] Google ScholarGoogle ScholarDigital LibraryDigital Library
  14. P. Johann. Short cut fusion: Proved and improved. In Semantics, Applications, and Implementation of Program Generation, Florence, Italy, Proceedings, volume 2196 of LNCS, pages 47--71. Springer-Verlag, 2001.]]Google ScholarGoogle ScholarDigital LibraryDigital Library
  15. A. Kühnemann, R. Glück, and K. Kakehi. Relating accumulative and non-accumulative functional programs. In Rewriting Techniques and Applications, Utrecht, The Netherlands, Proceedings, volume 2051 of LNCS, pages 154--168. Springer-Verlag, 2001.]] Google ScholarGoogle ScholarDigital LibraryDigital Library
  16. J. Launchbury and R. Paterson. Parametricity and unboxing with unpointed types. In European Symposium on Programming, Linköping, Sweden, Proceedings, volume 1058 of LNCS, pages 204--218. Springer-Verlag, 1996.]] Google ScholarGoogle ScholarDigital LibraryDigital Library
  17. D. Leivant. Polymorphic type inference. In Principles of Programming Languages, Austin, Texas, Proceedings, pages 88--98. ACM Press, 1983.]] Google ScholarGoogle ScholarDigital LibraryDigital Library
  18. B. McAdam. Repairing Type Errors in Functional Programs. PhD thesis, University of Edinburgh, 2002.]]Google ScholarGoogle Scholar
  19. A. Moran and D. Sands. Improvement in a lazy context: An operational theory for call-by-need. In Principles of Programming Languages, San Antonio, Texas, Proceedings, pages 43--56. ACM Press, 1999.]] Google ScholarGoogle ScholarDigital LibraryDigital Library
  20. S. Peyton Jones, W. Partain, and A. Santos. Let-floating: Moving bindings to give faster programs. In International Conference on Functional Programming, Philadelphia, Pennsylvania, Proceedings, pages 1--12. ACM Press, 1996.]] Google ScholarGoogle ScholarDigital LibraryDigital Library
  21. S. Peyton Jones and A. Santos. A transformation-based optimiser for Haskell. Sci. of Comput. Prog., 32:3--47, 1998.]] Google ScholarGoogle ScholarDigital LibraryDigital Library
  22. A. Pitts. Parametric polymorphism and operational equivalence. Math. Struct. Comput. Sci., 10:321--359, 2000.]] Google ScholarGoogle ScholarDigital LibraryDigital Library
  23. J. Reynolds. Types, abstraction and parametric polymorphism. In Information Processing, Paris, France, Proceedings, pages 513--523. Elsevier Science Publishers B.V., 1983.]]Google ScholarGoogle Scholar
  24. D. Schmidt. Denotational Semantics: A Methodology for Language Development. Allyn and Bacon, 1986.]] Google ScholarGoogle ScholarDigital LibraryDigital Library
  25. T. Sheard, Z. Benaissa, and M. Martel. Introduction to multi-stage programming using MetaML. http://cse.ogi.edu/~sheard/papers/manual.ps.]]Google ScholarGoogle Scholar
  26. J. Svenningsson. Shortcut fusion for accumulating parameters and zip-like functions. In International Conference on Functional Programming, Pittsburgh, Pennsylvania, Proceedings. ACM Press, 2002.]] Google ScholarGoogle ScholarDigital LibraryDigital Library
  27. P. Wadler. The concatenate vanishes. Note, University of Glasgow, 1987 (revised, 1989).]]Google ScholarGoogle Scholar
  28. P. Wadler. Theorems for free! In Functional Programming Languages and Computer Architecture, London, England, Proceedings, pages 347--359. ACM Press, 1989.]] Google ScholarGoogle ScholarDigital LibraryDigital Library
  29. J. Yang, G. Michaelson, P. Trinder, and J. Wells. Improved type error reporting. In Implementation of Functional Languages, Aachen, Germany, Draft Proceedings, pages 71--86, 2000.]]Google ScholarGoogle Scholar

Index Terms

  1. Concatenate, reverse and map vanish for free

                Recommendations

                Comments

                Login options

                Check if you have access through your login credentials or your institution to get full access on this article.

                Sign in

                Full Access

                • Published in

                  cover image ACM SIGPLAN Notices
                  ACM SIGPLAN Notices  Volume 37, Issue 9
                  September 2002
                  283 pages
                  ISSN:0362-1340
                  EISSN:1558-1160
                  DOI:10.1145/583852
                  Issue’s Table of Contents
                  • cover image ACM Conferences
                    ICFP '02: Proceedings of the seventh ACM SIGPLAN international conference on Functional programming
                    October 2002
                    294 pages
                    ISBN:1581134878
                    DOI:10.1145/581478

                  Copyright © 2002 ACM

                  Permission to make digital or hard copies of all or part of this work for personal or classroom use is granted without fee provided that copies are not made or distributed for profit or commercial advantage and that copies bear this notice and the full citation on the first page. Copyrights for components of this work owned by others than ACM must be honored. Abstracting with credit is permitted. To copy otherwise, or republish, to post on servers or to redistribute to lists, requires prior specific permission and/or a fee. Request permissions from [email protected]

                  Publisher

                  Association for Computing Machinery

                  New York, NY, United States

                  Publication History

                  • Published: 17 September 2002

                  Check for updates

                  Qualifiers

                  • article

                PDF Format

                View or Download as a PDF file.

                PDF

                eReader

                View online with eReader.

                eReader