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.
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
Abadi, M., Cardelli, L., Curien, P.-L., Levy, J.-J.: Explicit substitutions. J. of Funct. Program. 1(4), 375–416 (1991)
Fegaras, L.: Using the parametricity theorem for program fusion. Tech. report CSE-96-001. Oregon Grad. Inst. (1996)
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)
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)
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)
Gill, A.: Cheap Deforestation for Non-strict Functional Languages. PhD thesis. University of Glasgow (1996)
Gill, A., Hutton, G.: The worker/wrapper transformation. J. of Funct. Program. 19(2), 227–251 (2009)
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)
Hughes, J.: A novel representation of lists and its application to the function ‘reverse’. Inf. Process. Lett. 22(3), 141–144 (1986)
Hutton, G., Jaskelioff, M., Gill, A.: Factorising folds for faster functions. J. of Funct. Program. 20(3-4), 353–373 (2010)
Johann, P.: A generalization of short-cut fusion and its correctness proof. Higher-Order and Symb. Comput. 15(4), 273–300 (2002)
Johann, P.: Short-cut fusion is correct. J. of Funct. Program. 13(4), 797–814 (2003)
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)
Kmett, E.: Kan extensions 1–3. Posts on the author’s blog ‘The Comonad.Reader’ (2008), http://comonad.com/reader/
Kmett, E.: Free monads for less 1–3. Posts on the author’s blog ‘The Comonad.Reader’ (2011), http://comonad.com/reader/
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)
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)
Manzino, C., Pardo, A.: Shortcut fusion of monadic programs. J. of Univ. Comput. Sci. 14(21), 3431–3446 (2008)
Pavlovic, D.: Logic of build fusion. Techn. report KES.U.00.9. Kestrel Inst. (2000)
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)
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)
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)
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)
Uustalu, T.: Generalizing substitution. Theor. Inform. and Appl. 37(4), 315–336 (2003)
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)
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)
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)
Wadler, P.: Deforestation: transforming programs to eliminate trees. Theor. Comput. Sci. 73(2), 231–248 (1990)
Wadler, P.: Recursive types for free! Unpublished note (1990)
Wadler, P.: The concatenate vanishes. Unpublished note (1987, updated 1989)
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)
Author information
Authors and Affiliations
Editor information
Editors and Affiliations
Rights 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)