Hostname: page-component-848d4c4894-nmvwc Total loading time: 0 Render date: 2024-06-26T10:09:46.413Z Has data issue: false hasContentIssue false

Monadic augment and generalised short cut fusion

Published online by Cambridge University Press:  01 November 2007

NEIL GHANI
Affiliation:
University of Nottingham, Nottingham, NG7 2RD, UK email: nxg@cs.nott.ac.uk
PATRICIA JOHANN
Affiliation:
Rutgers University, Camden, NJ 08102, USA email: pjohann@crab.rutgers.edu
Rights & Permissions [Opens in a new window]

Abstract

Core share and HTML view are not available for this content. However, as you have access to this content, a full PDF is available via the ‘Save PDF’ action button.

Monads are commonplace programming devices that are used to uniformly structure computations; in particular, they are often used to mimic the effects of impure features such as state, error handling, and I/O. This paper further develops the monadic programming paradigm by investigating the extent to which monadic computations can be optimised by using generalisations of short cut fusion to eliminate monadic structures whose sole purpose is to “glue together” monadic program components. Ghani, Uustalu, and Vene have recently shown that every inductive type has an associated build combinator and an associated short cut fusion law. They have also used the notion of a parameterised monad to describe those monads that give rise to inductive types, and have shown that the standard augment combinators and cata/augment fusion rules for algebraic data types can be generalised to fixed points of all parameterised monads. We revisit these augment combinators and generalised short cut fusion rules for such types but consider them from a functional programming perspective, rather than a categorical one. In addition to making the category-theoretic ideas of Ghani, Uustalu, and Vene more easily accessible to a wider audience of functional programmers, we demonstrate their practical applicability by developing nontrivial application programs and performing modest benchmarking on them. We also show how the cata/augment rules can serve as the basis for deriving additional generic fusion laws, thus opening the way for an algebra of fusion. Finally, we offer deep theoretical insights, arguing that the augment combinators are monadic in nature, and thus that the cata/build and cata/augment rules are arguably the best generally applicable fusion rules obtainable.

Type
Article
Copyright
Copyright © Cambridge University Press 2007

References

Chitil, O. 1999. Type inference builds a short cut to deforestation. In International Conference on Functional Programming, Proceedings, ACM Press, pp. 249260.Google Scholar
Fegaras, L. and Sheard, T. 1996. Revisiting catamorphisms over datatypes with embedded functions. Principles of Programming Languages, Proceedings, ACM Press, pp. 284–194.Google Scholar
Ghani, N., Johann, P., Uustalu, T. and Vene, V. 2005. Monadic augment and generalised short cut fusion. In International Conference on Functional Programming, Proceedings, ACM Press, pp. 294305.Google Scholar
Ghani, N., Uustalu, T. and Vene, V. 2004. Build, augment and destroy. Universally. In Asian Symposium on Programming Languages, Proceedings, LNCS 3302, Springer-Verlag, pp. 327–347.Google Scholar
Ghani, N., Uustalu, T. and Vene, V. 2005. Generalizing the augment combinator. In Trends in Functional Programming 5, Intellect, pp. 65–78.Google Scholar
Gill, A. 1996. Cheap Deforestation for Non-strict Functional Languages. PhD thesis, Glasgow University.Google Scholar
Gill, A., Launchbury, J. and Peyton Jones, S. L. 1993. A short cut to deforestation. In Functional Programming Languages and Computer Architecture, Proceedings, ACM Press, pp. 223232.Google Scholar
Hu, Z., Iwasaki, H. and Takeichi, M. 1996. Deriving structural hylomorphisms from recursive definitions. In International Conference on Functional Programming, Proceedings, ACM Press, pp. 7382.Google Scholar
Johann, P. 2002. A generalization of short-cut fusion and its correctness proof. Higher-Order and Symbolic Computation, 15, 273300.CrossRefGoogle Scholar
Jürgensen, C. 2005. Categorical Semantics and Composition of Tree Transducers. PhD thesis, Technische Universität Dresden.Google Scholar
Launchbury, J., Krstic, S. and Sauerwein, T. 2000. Zip fusion with hyperfunctions. Available at www.cse.ogi.edu/~krstic.Google Scholar
Launchbury, J. and Sheard, T. 1995. Warm fusion: Deriving build-catas from recursive definitions. In Functional Programming and Computer Architecture, Proceedings, ACM Press, pp. 314323.Google Scholar
Malcolm, G. 1990. Algebraic Data Types and Program Transformation. PhD thesis, Rijksuniveriseit Gröningen.Google Scholar
Meijer, E. and Hutton, G. 1995. Bananas in space: Extending folds and unfolds to exponential types. In Functional Programming and Computer Architecture, Proceedings, ACM Press, pp. 324333.Google Scholar
Meijer, E. and Jeuring, J. 1995. Merging monads and folds for functional programming. In Advanced Functional Programming, Proceedings, LNCS 925, Springer-Verlag, pp. 228–266.Google Scholar
Moggi, E. 1991. Notions of computation and monads. Information & Computation, 93 (1), 5592.CrossRefGoogle Scholar
Pardo, A. 2001. Fusion of recursive programs with computational effects. Theoretical Computer Science 260 (1–2), 165207.CrossRefGoogle Scholar
Peyton Jones, S., Tolmach, A. and Hoare, T. 2001. Playing by the rules: Rewriting as an optimization technique in GHC. In Haskell Workshop, Proceedings, ACM Press, pp. 203233.Google Scholar
Peyton Jones, S. L. editor. 2003. Haskell 98 Language and Libraries: The Revised Report. Cambridge University Press.Google Scholar
Pitts, A. 2000. Parametric polymorphism and operational equivalence. Mathematical Structures Computer Science 10, 1397.CrossRefGoogle Scholar
Plotkin, G. and Power, J. 2002. Notions of computation determine monads. In Foundations of Software Science and Computation Structure, Proceedings, pp. 342–356.Google Scholar
Sheard, T. and Fegaras, L. 1993. A fold for all seasons. In Functional Programming Languages and Computer Architecture, Proceedings, ACM Press, pp. 233242.Google Scholar
Svenningsson, J. 2002. Shortcut fusion for accumulating parameters and zip-like functions. In International Conference on Functional Programming, Proceedings, ACM Press, pages 124132, 2002.Google Scholar
Takano, A. and Meijer, E. 1995. Shortcut deforestation in calculational form. In Functional Programming Languages and Computer Architecture, Proceedings, ACM Press, pp. 306313.Google Scholar
Uustalu, T. 2003. Generalizing substitution. Theoretical Informatics & Applications 37 (4), 315336.CrossRefGoogle Scholar
Voigtländer, J. 2002. Concatenate, reverse and map vanish for free. In International Conference on Functional Programming, Proceedings, ACM Press, pp. 1425.Google Scholar
Wadler, P. 1992. The essence of functional programming. In Principles of Programming Languages, Proceedings, ACM Press, pp. 114.Google Scholar
Submit a response

Discussions

No Discussions have been published for this article.