skip to main content
10.1145/1086365.1086403acmconferencesArticle/Chapter ViewAbstractPublication PagesicfpConference Proceedingsconference-collections
Article

Monadic augment and generalised short cut fusion

Published: 12 September 2005 Publication History

Abstract

Monads are commonplace programming devices that are used to uniformly structure computations with effects such as state, exceptions, 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.We make several contributions. First, we show that every inductive type has an associated build combinator and an associated short cut fusion rule. Second, we introduce the notion of an inductive monad to describe those monads that give rise to inductive types, and we give examples of such monads which are widely used in functional programming. Third, we generalise the standard augment combinators and cata/augment fusion rules for algebraic data types to types induced by inductive monads. This allows us to give the first cata/augment rules for some common data types, such as rose trees. Fourth, we demonstrate the practical applicability of our generalisations by providing Haskell implementations for all concepts and examples in the paper. Finally, we offer deep theoretical insights by showing that the augment combinators are monadic in nature, and thus that our cata/build and cata/augment rules are arguably the best generally applicable fusion rules obtainable.

References

[1]
O. Chitil. Type inference builds a short cut to deforestation. In International Conference on Functional Programming, Proceedings, pages 249--260, 1999.
[2]
L. Fegaras and T. Sheard. Revisiting catamorphisms over datatypes with embedded functions. In Principles of Programming Languages, Proceedings, pages 284--194, 1996.
[3]
N. Ghani, T. Uustalu, and V. Vene. Build, augment and destroy. Universally. In Asian Symposium on Programming Languages, Proceedings, pages 327--347. 2004.
[4]
N. Ghani, T. Uustalu, and V. Vene. Generalizing the AUGMENT combinator. In Trends in Functional Programming 5, 2005. To appear.
[5]
A. Gill. Cheap Deforestation for Non-strict Functional Languages. PhD thesis, Univ. of Glasgow, 1996.
[6]
A. Gill, J. Launchbury, and S. L. Peyton Jones. A short cut to deforestation. In Functional Programming Languages and Computer Architecture, Proceedings, pages 223--232, 1993.
[7]
Z. Hu, H. Iwasaki, and M. Takeichi. Deriving structural hylomorphisms from recursive definitions. In International Conference on Functional Programming, Proceedings, pages 73--82. 1996.
[8]
P. Johann. A generalization of short-cut fusion and its correctness proof. Higher-Order and Symbolic Computation, 15:273--300, 2002.
[9]
C. Juergensen. Using monads to fuse recursive programs (extended abstract). citeseer.ist.psu.edu/543861.html.
[10]
J. Launchbury, S. Krstic, and T. Sauerwein. Zip fusion with hyperfunctions. citeseer.ist.psu.edu/launchbury00zip.html.
[11]
E. Meijer and G. Hutton. Bananas in space: Extending folds and unfolds to exponential types. In Functional Programming and Computer Architecture, Proceedings, pages 324--333, 1995.
[12]
E. Meijer and J. Jeuring. Merging monads and folds for functional programming. In Advanced Functional Programming, Proceedings, pages 228--266, 1995.
[13]
E. Moggi. Notions of computation and monads. Information and Computation, 93(1):55--92, 1991.
[14]
A. Pardo. Fusion of recursive programs with computational effects. Theoretical Computer Science, 260(1--2):165--207, 2001.
[15]
S. Peyton Jones, A. Tolmach, and T. Hoare. Playing by the rules: Rewriting as an optimization technique in GHC. In Haskell Workshop, Proceedings, pages 203--233, 2001.
[16]
S. L. Peyton Jones, editor. Haskell 98 Language and Libraries: The Revised Report. Cambridge University Press, 2003.
[17]
A. Pitts. Parametric polymorphism and operational equivalence. Mathematical Structures in Computer Science, 10:1--397, 2000.
[18]
G. Plotkin and J. Power. Notions of computation determine monads. In Foundations of Software Science and Computation Structure, Proceedings, pages 342--356, 2002.
[19]
T. Sheard and L. Fegaras. A fold for all seasons. In Functional Programming Languages and Computer Architecture, Proceedings, pages 233--242. 1993.
[20]
J. Svenningsson. Shortcut fusion for accumulating parameters and zip-like functions. In International Conference on Functional Programming, Proceedings, pages 124--132, 2002.
[21]
A. Takano and E. Meijer. Shortcut deforestation in calculational form. In Functional Programming Languages and Computer Architecture, Proceedings, pages 306--313, 1995.
[22]
T. Uustalu. Generalizing substitution. Theoretical Informatics and Applications, 37(4):315--336, 2003.
[23]
J. Voigtl�nder. Concatenate, reverse and map vanish for free. In International Conference on Functional Programming, Proceedings, pages 14--25, 2002.
[24]
P. Wadler. The essence of functional programming. In Principles of Programming Languages, Proceedings, pages 1--14, 1992.

Cited By

View all
  • (2015)Fold-based fusion as a library: a generative programming pearlProceedings of the 6th ACM SIGPLAN Symposium on Scala10.1145/2774975.2774981(41-50)Online publication date: 13-Jun-2015
  • (2011)A foundation for GADTs and inductive familiesProceedings of the seventh ACM SIGPLAN workshop on Generic programming10.1145/2036918.2036927(59-70)Online publication date: 18-Sep-2011
  • (2009)A principled approach to programming with nested types in HaskellHigher-Order and Symbolic Computation10.1007/s10990-009-9047-722:2(155-189)Online publication date: 1-Jun-2009
  • Show More Cited By

Recommendations

Comments

Information & Contributors

Information

Published In

cover image ACM Conferences
ICFP '05: Proceedings of the tenth ACM SIGPLAN international conference on Functional programming
September 2005
342 pages
ISBN:1595930647
DOI:10.1145/1086365
  • cover image ACM SIGPLAN Notices
    ACM SIGPLAN Notices  Volume 40, Issue 9
    Proceedings of the tenth ACM SIGPLAN international conference on Functional programming
    September 2005
    330 pages
    ISSN:0362-1340
    EISSN:1558-1160
    DOI:10.1145/1090189
    Issue’s Table of Contents
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]

Sponsors

Publisher

Association for Computing Machinery

New York, NY, United States

Publication History

Published: 12 September 2005

Permissions

Request permissions for this article.

Check for updates

Author Tags

  1. augment
  2. bind
  3. build
  4. monads
  5. short cut fusion

Qualifiers

  • Article

Conference

ICFP05
Sponsor:

Acceptance Rates

Overall Acceptance Rate 333 of 1,064 submissions, 31%

Upcoming Conference

ICFP '25
ACM SIGPLAN International Conference on Functional Programming
October 12 - 18, 2025
Singapore , Singapore

Contributors

Other Metrics

Bibliometrics & Citations

Bibliometrics

Article Metrics

  • Downloads (Last 12 months)9
  • Downloads (Last 6 weeks)0
Reflects downloads up to 22 Oct 2024

Other Metrics

Citations

Cited By

View all
  • (2015)Fold-based fusion as a library: a generative programming pearlProceedings of the 6th ACM SIGPLAN Symposium on Scala10.1145/2774975.2774981(41-50)Online publication date: 13-Jun-2015
  • (2011)A foundation for GADTs and inductive familiesProceedings of the seventh ACM SIGPLAN workshop on Generic programming10.1145/2036918.2036927(59-70)Online publication date: 18-Sep-2011
  • (2009)A principled approach to programming with nested types in HaskellHigher-Order and Symbolic Computation10.1007/s10990-009-9047-722:2(155-189)Online publication date: 1-Jun-2009
  • (2008)Foundations for structured programming with GADTsACM SIGPLAN Notices10.1145/1328897.132847543:1(297-308)Online publication date: 7-Jan-2008
  • (2008)Foundations for structured programming with GADTsProceedings of the 35th annual ACM SIGPLAN-SIGACT symposium on Principles of programming languages10.1145/1328438.1328475(297-308)Online publication date: 7-Jan-2008
  • (2008)Algebraic fusion of functions with an accumulating parameter and its improvementJournal of Functional Programming10.1017/S095679680800693X18:5-6(781-819)Online publication date: 1-Sep-2008
  • (2008)Asymptotic Improvement of Computations over Free MonadsProceedings of the 9th international conference on Mathematics of Program Construction10.1007/978-3-540-70594-9_20(388-403)Online publication date: 15-Jul-2008
  • (2007)Initial algebra semantics is enough!Proceedings of the 8th international conference on Typed lambda calculi and applications10.5555/1770203.1770219(207-222)Online publication date: 26-Jun-2007
  • (2007)Lightweight fusion by fixed point promotionProceedings of the 34th annual ACM SIGPLAN-SIGACT symposium on Principles of programming languages10.1145/1190216.1190241(143-154)Online publication date: 17-Jan-2007
  • (2007)Lightweight fusion by fixed point promotionACM SIGPLAN Notices10.1145/1190215.119024142:1(143-154)Online publication date: 17-Jan-2007
  • Show More Cited By

View Options

Get Access

Login options

View options

PDF

View or Download as a PDF file.

PDF

eReader

View online with eReader.

eReader

Media

Figures

Other

Tables

Share

Share

Share this Publication link

Share on social media