skip to main content
10.1145/1596638.1596641acmconferencesArticle/Chapter ViewAbstractPublication PagesicfpConference Proceedingsconference-collections
research-article

Losing functions without gaining data: another look at defunctionalisation

Published: 03 September 2009 Publication History

Abstract

We describe a transformation which takes a higher-order program, and produces an equivalent first-order program. Unlike Reynolds-style defunctionalisation, it does not introduce any new data types, and the results are more amenable to subsequent analysis operations. We can use our method to improve the results of existing analysis operations, including strictness analysis, pattern-match safety and termination checking. Our transformation is implemented, and works on a Core language to which Haskell programs can be reduced. Our method cannot always succeed in removing all functional values, but in practice is remarkably successful.

Supplementary Material

JPG File (losingfunctionswithoutgainingdata-anotherlookatdefunctionalisationonvimeo.jpg)
MP4 File (losingfunctionswithoutgainingdata-anotherlookatdefunctionalisationonvimeo.mp4)

References

[1]
Andreas Abel. foetus -- Termination Checker for Simple Functional Programs. Programming Lab Report, July 1998.
[2]
Franz Baader and Tobias Nipkow. Term Rewriting and All That. Cambridge University Press, 1998.
[3]
Jeffrey M. Bell, Francoise Bellegarde, and James Hook. Type-driven defunctionalization. In Proc. ICFP '97, pages 25--37. ACM, 1997.
[4]
Urban Boquist and Thomas Johnsson. The GRIN project: A highly optimising back end for lazy functional languages. In Proc IFL '96, volume 1268 of LNCS, pages 58--84. Springer-Verlag, 1996.
[5]
Henry Cejtin, Suresh Jagannathan, and Stephen Weeks. Flow-directed closure conversion for typed languages. In Proc. ESOP '00, volume 1782 of LNCS, pages 56--71. Springer-Verlang, 2000.
[6]
Wei-Ngan Chin and John Darlington. A higher-order removal method. Lisp Symb. Comput., 9(4):287--322, 1996.
[7]
Duncan Coutts, Roman Leshchinskiy, and Don Stewart. Stream fusion: From lists to streams to nothing at all. In Proc ICFP '07, pages 315--326. ACM Press, October 2007.
[8]
Olivier Danvy and Lasse R. Nielsen. Defunctionalization at work. In Proc. PPDP '01, pages 162--174. ACM, 2001.
[9]
J. Giesl, P. Schneider-Kamp, and R. Thiemann. AProVE 1.2: Automatic termination proofs in the dependency pair framework. In Proceedings of the 3rd International Joint Conference on Automated Reasoning (IJCAR '06), volume 4130 of LNCS, pages 281--286. Springer-Verlag, 2006.
[10]
Dimitry Golubovsky, Neil Mitchell, and Matthew Naylor. Yhc.Core -- from Haskell to Core. The Monad.Reader, 1(7):45--61, April 2007.
[11]
John Hughes. A novel representation of lists and its application to the function "reverse". Inf. Process. Lett., 22(3):141--144, 1986.
[12]
Graham Hutton and Joel Wright. Calculating an Exceptional Machine. In Trends in Functional Programming volume 5. Intellect, February 2006.
[13]
Thomas Johnsson. Lambda lifting: transforming programs to recursive equations. In Proc. FPCA '85, pages 190--203. Springer-Verlag New York, Inc., 1985.
[14]
Mark P. Jones. Dictionary-free Overloading by Partial Evaluation. In Proc. PEPM '94, pages 107--117. ACM Press, June 1994.
[15]
Neil D. Jones, Carsten K. Gomard, and Peter Sestoft. Partial Evaluation and Automatic Program Generation. Prentice-Hall International, 1993.
[16]
Peter Jonsson and Johan Nordlander. Positive supercompilation for a higher order call-by-value language. In POPL '09, pages 277--288. ACM, 2009.
[17]
J B Kruskal. Well-quasi-ordering, the tree theorem, and Vazsonyi's conjecture. Transactions of the American Mathematical Society, 95(2):210--255, 1960.
[18]
John Meacham. jhc: John's haskell compiler. http://repetae.net/john/computer/jhc/, 2008.
[19]
Robin Milner, Mads Tofte, Robert Harper, and David MacQueen. The Definition of Standard ML -- Revised. The MIT Press, May 1997.
[20]
Neil Mitchell. Transformation and Analysis of Functional Programs. PhD thesis, University of York, 2008.
[21]
Neil Mitchell and Colin Runciman. Not all patterns, but enough -- an automatic verifier for partial but sufficient pattern matching. In Proc. Haskell '08, 2008.
[22]
George Nelan. Firstification. PhD thesis, Arizona State University, December 1991.
[23]
Ulf Norell. Dependently typed programming in Agda. In Lecture notes on Advanced Functional Programming, 2008.
[24]
Will Partain et al. The nofib Benchmark Suite of Haskell Programs. http://darcs.haskell.org/nofib/, 2008.
[25]
Simon Peyton Jones. Haskell 98 Language and Libraries: The Revised Report. Cambridge University Press, 2003.
[26]
Simon Peyton Jones. Call-pattern specialisation for Haskell programs. In Proc. ICFP '07, pages 327--337. ACM Press, October 2007.
[27]
Simon Peyton Jones and Simon Marlow. Secrets of the Glasgow Haskell Compiler inliner. JFP, 12:393--434, July 2002.
[28]
Simon Peyton Jones and Andres Santos. Compilation by transformation in the Glasgow Haskell Compiler. In Functional Programming Workshops in Computing, pages 184--204. Springer-Verlag, 1994.
[29]
Francois Pottier and Nadji Gauthier. Polymorphic typed defunctionalization. In Proc. POPL '04, pages 89--98. ACM Press, 2004.
[30]
John C. Reynolds. Definitional interpreters for higher-order programming languages. In Proc. ACM '72, pages 717--740. ACM Press, 1972.
[31]
Damien Sereni. Termination analysis and call graph construction for higherorder functional programs. In Proc. ICFP '07, pages 71--84. ACM, 2007.
[32]
The GHC Team. The GHC compiler, version 6.8.2. http://www.haskell.org/ghc/, December 2007.
[33]
Valentin F. Turchin. The concept of a supercompiler. ACM Trans. Program. Lang. Syst., 8(3):292--325, 1986.
[34]
Philip Wadler. Deforestation: Transforming programs to eliminate trees. In Proc ESOP '88, volume 300 of LNCS, pages 344--358. Berlin: Springer-Verlag, 1988.
[35]
Philip Wadler and Stephen Blott. How to make ad-hoc polymorphism less ad hoc. In Proc. POPL '89, pages 60--76. ACM Press, 1989.

Cited By

View all
  • (2024)Intensional FunctionsProceedings of the ACM on Programming Languages10.1145/36897148:OOPSLA2(87-112)Online publication date: 8-Oct-2024
  • (2020)Garbage collection using a finite liveness domainProceedings of the 2020 ACM SIGPLAN International Symposium on Memory Management10.1145/3381898.3397208(1-15)Online publication date: 16-Jun-2020
  • (2019)A static slicing method for functional programs and its incremental versionProceedings of the 28th International Conference on Compiler Construction10.1145/3302516.3307345(53-64)Online publication date: 16-Feb-2019
  • Show More Cited By

Index Terms

  1. Losing functions without gaining data: another look at defunctionalisation

    Recommendations

    Comments

    Information & Contributors

    Information

    Published In

    cover image ACM Conferences
    Haskell '09: Proceedings of the 2nd ACM SIGPLAN symposium on Haskell
    September 2009
    148 pages
    ISBN:9781605585086
    DOI:10.1145/1596638
    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: 03 September 2009

    Permissions

    Request permissions for this article.

    Check for updates

    Author Tags

    1. defunctionalisation
    2. firstification
    3. haskell

    Qualifiers

    • Research-article

    Conference

    ICFP '09
    Sponsor:

    Acceptance Rates

    Overall Acceptance Rate 57 of 143 submissions, 40%

    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)5
    • Downloads (Last 6 weeks)1
    Reflects downloads up to 05 Mar 2025

    Other Metrics

    Citations

    Cited By

    View all
    • (2024)Intensional FunctionsProceedings of the ACM on Programming Languages10.1145/36897148:OOPSLA2(87-112)Online publication date: 8-Oct-2024
    • (2020)Garbage collection using a finite liveness domainProceedings of the 2020 ACM SIGPLAN International Symposium on Memory Management10.1145/3381898.3397208(1-15)Online publication date: 16-Jun-2020
    • (2019)A static slicing method for functional programs and its incremental versionProceedings of the 28th International Conference on Compiler Construction10.1145/3302516.3307345(53-64)Online publication date: 16-Feb-2019
    • (2019)Predicate Specialization for Definitional Higher-Order Logic ProgramsLogic-Based Program Synthesis and Transformation10.1007/978-3-030-13838-7_8(132-147)Online publication date: 23-Feb-2019
    • (2017)Verifying distributed programs via canonical sequentializationProceedings of the ACM on Programming Languages10.1145/31339341:OOPSLA(1-27)Online publication date: 12-Oct-2017
    • (2016)Liveness-based garbage collection for lazy languagesACM SIGPLAN Notices10.1145/3241624.292669851:11(122-133)Online publication date: 14-Jun-2016
    • (2016)Liveness-based garbage collection for lazy languagesProceedings of the 2016 ACM SIGPLAN International Symposium on Memory Management10.1145/2926697.2926698(122-133)Online publication date: 14-Jun-2016
    • (2013)Using Rewriting to Synthesize Functional Languages to Digital CircuitsRevised Selected Papers of the 14th International Symposium on Trends in Functional Programming - Volume 832210.1007/978-3-642-45340-3_2(17-33)Online publication date: 14-May-2013

    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