skip to main content
10.1145/2620678.2620679acmotherconferencesArticle/Chapter ViewAbstractPublication PagesiflConference Proceedingsconference-collections
research-article

The Under-Performing Unfold: A new approach to optimising corecursive programs

Published: 28 August 2013 Publication History

Abstract

This paper presents a new approach to optimising corecursive programs by factorisation. In particular, we focus on programs written using the corecursion operator unfold. We use and expand upon the proof techniques of guarded coinduction and unfold fusion, capturing a pattern of generalising coinductive hypotheses by means of abstraction and representation functions. The pattern we observe is simple, has not been observed before, and is widely applicable. We develop a general program factorisation theorem from this pattern, demonstrating its utility with a range of practical examples.

References

[1]
R. Bird and P. Wadler. Introduction to Functional Programming. Prentice Hall International Series in Computer Science. 1988.
[2]
O. Chitil. Type Inference Builds a Short Cut to Deforestation. In ICFP '99. ACM, 1999.
[3]
T. Coquand. Infinite Objects in Type Theory. In TYPES '93, volume 806 of Lecture Notes in Computer Science. Springer, 1993.
[4]
D. Coutts, R. Leshchinskiy, and D. Stewart. Stream Fusion: From Lists to Streams to Nothing at All. In ICFP '07. ACM, 2007.
[5]
A. Farmer, A. Gill, E. Komp, and N. Sculthorpe. The HERMIT in the Machine: A Plugin for the Interactive Transformation of GHC Core Language Programs. In Haskell Symposium (Haskell '12). ACM, 2012.
[6]
P. J. Freyd. Remarks on Algebraically Compact Categories. In Applications of Categories in Computer Science, volume 177 of London Mathematical Society Lecture Note Series. Cambridge University Press, 1992.
[7]
J. Gibbons. Fission for Program Comprehension. In MPC '06, volume 4014 of Lecture Notes in Computer Science. Springer, 2006.
[8]
J. Gibbons and G. Hutton. Proof Methods for Corecursive Programs. Fundamenta Informaticae Special Issue on Program Transformation, 66(4), April-May 2005.
[9]
J. Gibbons and G. Jones. The Under-Appreciated Unfold. In ICFP '98. ACM, 1998.
[10]
A. Gill and G. Hutton. The Worker/Wrapper Transformation. Journal of Functional Programming, 19(2), Mar. 2009.
[11]
A. J. Gill, J. Launchbury, and S. L. Peyton Jones. A Short Cut to Deforestation. In FPCA '93. Springer, 1993.
[12]
A. D. Gordon. A Tutorial on Co-induction and Functional Programming. In In Glasgow Functional Programming Workshop. Springer, 1994.
[13]
T. Hagino. A Categorical Programming Language. PhD thesis, Department of Computer Science, University of Edinburgh, 1987.
[14]
R. Hinze. Functional Pearl: Streams and Unique Fixed Points. In ICFP '08, New York, NY, USA, 2008.
[15]
G. Hutton, M. Jaskelioff, and A. Gill. Factorising Folds for Faster Functions. Journal of Functional Programming Special Issue on Generic Programming, 20(3&4), June 2010.
[16]
K. E. Iverson. A Programming Language. Wiley, 1962.
[17]
G. Malcolm. Algebraic Data Types and Program Transformation. PhD thesis, Rijksuniversiteit Groningen, 1990.
[18]
E. Meijer, M. M. Fokkinga, and R. Paterson. Functional Programming with Bananas, Lenses, Envelopes and Barbed Wire. In FPCA '91, volume 523 of Lecture Notes in Computer Science. Springer, 1991.
[19]
A. Moran and D. Sands. Improvement in a Lazy Context: An Operational Theory for Call-by-Need. In POPL '99, pages 43--56. ACM, 1999.
[20]
L. S. Moss and N. Danner. On the Foundations of Corecursion. Logic Journal of the IGPL, 5(2), 1997.
[21]
A. Pardo. Monadic Corecursion --- Definition, Fusion Laws, and Applications. Electr. Notes Theor. Comput. Sci., 11, 1998.
[22]
S. Peyton Jones, editor. Haskell 98 Language and Libraries: The Revised Report. Cambridge University Press, 2003.
[23]
S. Peyton Jones. Call-Pattern Specialisation for Haskell Programs. In ICFP '07. ACM, 2007.
[24]
N. Sculthorpe and G. Hutton. Work It, Wrap It, Fix It, Fold It. Submitted to the Journal of Functional Programming, 2013.
[25]
N. Sculthorpe, A. Farmer, and A. Gill. The HERMIT in the Tree: Mechanizing Program Transformations in the GHC Core Language. In Draft Proceedings of Implementation and Application of Functional Languages (IFL '12), 2012.
[26]
A. Takano and E. Meijer. Shortcut Deforestation in Calculational Form. In FPCA '95. Springer, 1995.
[27]
D. A. Turner. Miranda System Manual. Research Software Ltd., Canterbury, England, 1989. Available online at http://miranda.org.uk/.
[28]
D. A. Turner. Elementary Strong Functional Programming. In FPLE '95, volume 1022 of Lecture Notes in Computer Science. Springer, 1995.
[29]
T. Uustalu and V. Vene. Primitive (Co)Recursion and Course-of-Value (Co)Iteration, Categorically. Informatica, Lith. Acad. Sci., 10 (1), 1999.
[30]
J. Voigtländer. Proving Correctness via Free Theorems: The Case of the destroy/build-Rule. In PEPM '08. ACM, 2008.
[31]
P. Wadler. Deforestation: Transforming Programs to Eliminate Trees. Theor. Comput. Sci., 73(2), 1990.

Cited By

View all
  • (2015)Programs for Cheap!Proceedings of the 2015 30th Annual ACM/IEEE Symposium on Logic in Computer Science (LICS)10.1109/LICS.2015.21(115-126)Online publication date: 6-Jul-2015
  • (2014)Worker/wrapper/makes it/fasterACM SIGPLAN Notices10.1145/2692915.262814249:9(95-107)Online publication date: 19-Aug-2014

Index Terms

  1. The Under-Performing Unfold: A new approach to optimising corecursive programs

    Recommendations

    Comments

    Information & Contributors

    Information

    Published In

    cover image ACM Other conferences
    IFL '13: Proceedings of the 25th symposium on Implementation and Application of Functional Languages
    August 2013
    146 pages
    ISBN:9781450329880
    DOI:10.1145/2620678
    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 the author(s) 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: 28 August 2013

    Permissions

    Request permissions for this article.

    Check for updates

    Author Tags

    1. coinduction
    2. factorisation
    3. fusion
    4. unfolds

    Qualifiers

    • Research-article
    • Research
    • Refereed limited

    Conference

    IFL '13

    Acceptance Rates

    Overall Acceptance Rate 19 of 36 submissions, 53%

    Contributors

    Other Metrics

    Bibliometrics & Citations

    Bibliometrics

    Article Metrics

    • Downloads (Last 12 months)2
    • Downloads (Last 6 weeks)1
    Reflects downloads up to 17 Feb 2025

    Other Metrics

    Citations

    Cited By

    View all
    • (2015)Programs for Cheap!Proceedings of the 2015 30th Annual ACM/IEEE Symposium on Logic in Computer Science (LICS)10.1109/LICS.2015.21(115-126)Online publication date: 6-Jul-2015
    • (2014)Worker/wrapper/makes it/fasterACM SIGPLAN Notices10.1145/2692915.262814249:9(95-107)Online publication date: 19-Aug-2014

    View Options

    Login options

    View options

    PDF

    View or Download as a PDF file.

    PDF

    eReader

    View online with eReader.

    eReader

    Figures

    Tables

    Media

    Share

    Share

    Share this Publication link

    Share on social media