Skip to main content

Explicit Binds: Effortless Efficiency with and without Trees

  • Conference paper
Functional and Logic Programming (FLOPS 2012)

Part of the book series: Lecture Notes in Computer Science ((LNTCS,volume 7294))

Included in the following conference series:

Abstract

We demonstrate a simple and robust program transformation technique that can improve asymptotic time complexity of data-manipulating programs (e.g., produce a linear-time list reversal function from the obvious quadratic one). In the version of the present paper, it applies to monadic inductive datatypes and can be stated in two flavors, through a datatype representation, with an explicit (“frozen”) bind constructor and a special associated defining clause for the fold function, and in a functional form (generalized Church numerals), with a special definition of the bind function in terms of the build constructor. The technique explicates, systematizes, combines and scales a number of ideas known from the literature, achieving a new level of generality.

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

Access this chapter

Chapter
USD 29.95
Price excludes VAT (USA)
  • Available as PDF
  • Read on any device
  • Instant download
  • Own it forever
eBook
USD 39.99
Price excludes VAT (USA)
  • Available as PDF
  • Read on any device
  • Instant download
  • Own it forever
Softcover Book
USD 54.99
Price excludes VAT (USA)
  • Compact, lightweight edition
  • Dispatched in 3 to 5 business days
  • Free shipping worldwide - see info

Tax calculation will be finalised at checkout

Purchases are for personal use only

Institutional subscriptions

Preview

Unable to display preview. Download preview PDF.

Unable to display preview. Download preview PDF.

References

  1. Abadi, M., Cardelli, L., Curien, P.-L., Levy, J.-J.: Explicit substitutions. J. of Funct. Program. 1(4), 375–416 (1991)

    Article  MathSciNet  MATH  Google Scholar 

  2. Fegaras, L.: Using the parametricity theorem for program fusion. Tech. report CSE-96-001. Oregon Grad. Inst. (1996)

    Google Scholar 

  3. Ghani, N., Johann, P.: Short cut fusion for effects. In: Achten, P., Koopman, P., Morazán, M. (eds.) Trends in Functional Programming, vol. 9, pp. 113–128. Intellect, Bristol (2009)

    Google Scholar 

  4. Ghani, N., Uustalu, T., Vene, V.: Build, Augment and Destroy, Universally. In: Chin, W.-N. (ed.) APLAS 2004. LNCS, vol. 3302, pp. 327–347. Springer, Heidelberg (2004)

    Chapter  Google Scholar 

  5. Ghani, N., Uustalu, T., Vene, V.: Generalizing the augment combinator. In: Loidl, H.-W. (ed.) Trends in Functional Programming, vol. 5, pp. 65–78. Intellect, Bristol (2006)

    Google Scholar 

  6. Gill, A.: Cheap Deforestation for Non-strict Functional Languages. PhD thesis. University of Glasgow (1996)

    Google Scholar 

  7. Gill, A., Hutton, G.: The worker/wrapper transformation. J. of Funct. Program. 19(2), 227–251 (2009)

    Article  MATH  Google Scholar 

  8. Gill, A., Launchbury, J., Peyton Jones, S.L.: A short cut to deforestation. In: Conf. Record of 6th ACM SIGPLAN/SIGARCH Int. Conf. on Functional Programming Languages and Computer Architecture, FPCA 1993, Copenhagen, pp. 223–232. ACM Press, New York (1993)

    Chapter  Google Scholar 

  9. Hughes, J.: A novel representation of lists and its application to the function ‘reverse’. Inf. Process. Lett. 22(3), 141–144 (1986)

    Article  Google Scholar 

  10. Hutton, G., Jaskelioff, M., Gill, A.: Factorising folds for faster functions. J. of Funct. Program. 20(3-4), 353–373 (2010)

    Article  MATH  Google Scholar 

  11. Johann, P.: A generalization of short-cut fusion and its correctness proof. Higher-Order and Symb. Comput. 15(4), 273–300 (2002)

    Article  MATH  Google Scholar 

  12. Johann, P.: Short-cut fusion is correct. J. of Funct. Program. 13(4), 797–814 (2003)

    Article  MathSciNet  MATH  Google Scholar 

  13. Jürgensen, C., Vogler, H.: Syntactic composition of top-down tree transducers is short cut fusion. Math. Struct. in Comput. Sci. 14(2), 215–282 (2004)

    Article  MATH  Google Scholar 

  14. Kmett, E.: Kan extensions 1–3. Posts on the author’s blog ‘The Comonad.Reader’ (2008), http://comonad.com/reader/

  15. Kmett, E.: Free monads for less 1–3. Posts on the author’s blog ‘The Comonad.Reader’ (2011), http://comonad.com/reader/

  16. Kühnemann, A.: Comparison of Deforestation Techniques for Functional Programs and for Tree Transducers. In: Middeldorp, A., Sato, T. (eds.) FLOPS 1999. LNCS, vol. 1722, pp. 114–130. Springer, Heidelberg (1999)

    Chapter  Google Scholar 

  17. Kühnemann, A., Maletti, A.: The Substitution Vanishes. In: Johnson, M., Vene, V. (eds.) AMAST 2006. LNCS, vol. 4019, pp. 173–188. Springer, Heidelberg (2006)

    Chapter  Google Scholar 

  18. Manzino, C., Pardo, A.: Shortcut fusion of monadic programs. J. of Univ. Comput. Sci. 14(21), 3431–3446 (2008)

    MATH  Google Scholar 

  19. Pavlovic, D.: Logic of build fusion. Techn. report KES.U.00.9. Kestrel Inst. (2000)

    Google Scholar 

  20. Peyton Jones, S.L., Launchbury, J.: Unboxed Values as First Class Citizens in a Non-strict Functional Language. In: Hughes, J. (ed.) FPCA 1991. LNCS, vol. 523, pp. 636–666. Springer, Heidelberg (1991)

    Chapter  Google Scholar 

  21. Seidel, D., Voigtländer, J.: Improvements for free. In: Massink, M., Norman, G. (eds.) Proc. of 9th Wksh. on Quantitative Aspects of Programming Languages, QAPL 2011, Saarbrücken. Electron. Proc. in Theor. Comput. Sci., vol. 57, pp. 89–103. Elsevier, Amsterdam (2011)

    Google Scholar 

  22. Svenningsson, J.: Shortcut fusion for accumulating parameters & zip-like functions. In: Proc. of 7th ACM SIGPLAN Int. Conf. on Functional Programming, ICFP 2002, Pittsburgh, PA, pp. 124–132. ACM Press, New York (2002)

    Chapter  Google Scholar 

  23. Takano, A., Meijer, E.: Shortcut deforestation in calculational form. In: Conf. Record of 7th ACM SIGPLAN/SIGARCH Conf. on Functional Programming Languages and Computer Architecture, FPCA 1995, La Jolla, pp. 306–316. ACM Press, New York (1995)

    Google Scholar 

  24. Uustalu, T.: Generalizing substitution. Theor. Inform. and Appl. 37(4), 315–336 (2003)

    Article  MathSciNet  MATH  Google Scholar 

  25. Uustalu, T., Vene, V.: The Essence of Dataflow Programming. In: Horváth, Z. (ed.) CEFP 2005. LNCS, vol. 4164, pp. 135–167. Springer, Heidelberg (2006)

    Chapter  Google Scholar 

  26. Voigtländer, J.: Asymptotic Improvement of Computations over Free Monads. In: Audebaud, P., Paulin-Mohring, C. (eds.) MPC 2008. LNCS, vol. 5133, pp. 388–403. Springer, Heidelberg (2008)

    Chapter  Google Scholar 

  27. Voigtländer, J.: Concatenate, reverse and map vanish for free. In: Proc. of 7th Int. Conf. on Functional Programming, ICFP 2002, Pittsburgh, PA, pp. 14–25. ACM Press, New York (2002)

    Google Scholar 

  28. Wadler, P.: Deforestation: transforming programs to eliminate trees. Theor. Comput. Sci. 73(2), 231–248 (1990)

    Article  MathSciNet  MATH  Google Scholar 

  29. Wadler, P.: Recursive types for free! Unpublished note (1990)

    Google Scholar 

  30. Wadler, P.: The concatenate vanishes. Unpublished note (1987, updated 1989)

    Google Scholar 

  31. Wadler, P.: Theorems for free! In: Proc. of 4th Int. Conf. on Functional Programming Languages and Computer Architecture, FPCA 1989, London, pp. 347–359. ACM Press, New York (1989)

    Chapter  Google Scholar 

Download references

Author information

Authors and Affiliations

Authors

Editor information

Editors and Affiliations

Rights and permissions

Reprints and permissions

Copyright information

© 2012 Springer-Verlag Berlin Heidelberg

About this paper

Cite this paper

Uustalu, T. (2012). Explicit Binds: Effortless Efficiency with and without Trees. In: Schrijvers, T., Thiemann, P. (eds) Functional and Logic Programming. FLOPS 2012. Lecture Notes in Computer Science, vol 7294. Springer, Berlin, Heidelberg. https://doi.org/10.1007/978-3-642-29822-6_25

Download citation

  • DOI: https://doi.org/10.1007/978-3-642-29822-6_25

  • Publisher Name: Springer, Berlin, Heidelberg

  • Print ISBN: 978-3-642-29821-9

  • Online ISBN: 978-3-642-29822-6

  • eBook Packages: Computer ScienceComputer Science (R0)

Publish with us

Policies and ethics