Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
skip to main content
10.1145/2364506.2364508acmconferencesArticle/Chapter ViewAbstractPublication PagesicfpConference Proceedingsconference-collections
research-article

The HERMIT in the machine: a plugin for the interactive transformation of GHC core language programs

Published: 13 September 2012 Publication History

Abstract

The importance of reasoning about and refactoring programs is a central tenet of functional programming. Yet our compilers and development toolchains only provide rudimentary support for these tasks. This paper introduces a programmatic and compiler-centric interface that facilitates refactoring and equational reasoning. To develop our ideas, we have implemented HERMIT, a toolkit enabling informal but systematic transformation of Haskell programs from inside the Glasgow Haskell Compiler's optimization pipeline. With HERMIT, users can experiment with optimizations and equational reasoning, while the tedious heavy lifting of performing the actual transformations is done for them.
HERMIT provides a transformation API that can be used to build higher-level rewrite tools. One use-case is prototyping new optimizations as clients of this API before being committed to the GHC toolchain. We describe a HERMIT application - a read-eval-print shell for performing transformations using HERMIT. We also demonstrate using this shell to prototype an optimization on a specific example, and report our initial experiences and remaining challenges.

References

[1]
F. L. Bauer, H. Ehler, A. Horsch, B. Moeller, H. Partsch, O. Paukner, and P. Pepper. The Munich Project CIP. Springer-Verlag, 1988.
[2]
Y. Bertot and P. Castéran. Interactive Theorem Proving and Program Development. Springer, 2004.
[3]
R. Bird and O. de Moor. Algebra of Programming. Prentice Hall, 1997.
[4]
P. Borovanský, C. Kirchner, H. Kirchner, and C. Ringeissen. Rewriting with strategies in ELAN: a functional semantics. International Journal of Foundations of Computer Science, 12 (1): 69--98, 2001.
[5]
M. Bravenboer, K. T. Kalleberg, R. Vermaas, and E. Visser. Stratego/XT 0.17. A language and toolset for program transformation. Science of Computer Programming, 72 (1-2): 52--70, 2008.
[6]
C. M. Brown. Tool Support for Refactoring Haskell Programs. PhD thesis, University of Kent, 2008.
[7]
A. Bundy, D. Basin, D. Hutter, and A. Ireland. Rippling: Meta-Level Guidance for Mathematical Reasoning. Cambridge University Press, 2005.
[8]
R. M. Burstall and J. Darlington. A transformation system for developing recursive programs. Journal of the ACM, 24 (1): 44--67, 1977.
[9]
D. Delahaye. A tactic language for the system Coq. In Logic for Programming and Automated Reasoning, pages 85--95. Springer, 2000.
[10]
E. Dolstra. First class rules and generic traversals for program transformation languages. Technical report, Utrecht University, 2001.
[11]
N. J. Foster, M. B. Greenwald, J. T. Moore, B. C. Pierce, and A. Schmitt. Combinators for bidirectional tree transformations: A linguistic approach to the view-update problem. Transactions on Programming Languages and Systems, 29 (3), 2007.
[12]
GHC Team. The Glorious Glasgow Haskell Compilation System User's Guide, Version 7.4.1, 2012. URL http://www.haskell.org/ghc.
[13]
A. Gill. Introducing the Haskell equational reasoning assistant. In Haskell Workshop, pages 108--109. ACM, 2006.
[14]
A. Gill. A Haskell hosted DSL for writing transformation systems. In Domain-Specific Languages, pages 285--309. Springer, 2009.
[15]
A. Gill and G. Hutton. The worker/wrapper transformation. Journal of Functional Programming, 19 (2): 227--251, 2009.
[16]
W. Guttmann, H. Partsch, W. Schulte, and T. Vullinghs. Tool support for the interactive derivation of formally correct functional programs. Journal of Universal Computer Science, 9 (2): 173--188, 2003.
[17]
J. Harrison. Handbook of Practical Logic and Automated Reasoning. Cambridge University Press, 2009.
[18]
R. Hinze. A new approach to generic functional programming. In Principles of Programming Languages, pages 119--132. ACM, 2000.
[19]
R. Hughes. A novel representation of lists and its application to the function "reverse". Information Processing Letters, 22 (3): 141--144, 1986.
[20]
O. Kiselyov, S. Peyton Jones, and C. Shan. Fun with type functions. In Reflections on the Work of C.A.R. Hoare, chapter 14, pages 301--331. Springer, 2010.
[21]
R. Lämmel and S. Peyton Jones. Scrap your boilerplate: a practical design pattern for generic programming. In Types in Languages Design and Implementation, pages 26--37. ACM, 2003.
[22]
R. Lämmel and S. Peyton Jones. Scrap more boilerplate: reflection, zips, and generalised casts. In International Conference on Functional Programming, pages 244--255. ACM, 2004.
[23]
R. Lämmel and J. Visser. Typed combinators for generic traversal. In Practical Aspects of Declarative Programming, pages 137--154. Springer, 2002.
[24]
R. Lämmel, S. Thompson, and M. Kaiser. Programming errors in traversal programs over structured data. Science of Computer Programming, 2013. To appear.
[25]
H. Li and S. Thompson. Tool support for refactoring functional programs. In Partial evaluation and semantics-based program manipulation, pages 199--203. ACM, 2008.
[26]
A. Löh. Exploring Generic Haskell. PhD thesis, Utrecht University, 2004.
[27]
J. P. Magalhães, A. Dijkstra, J. Jeuring, and A. Löh. A generic deriving mechanism for Haskell. In Haskell Symposium, pages 37--48. ACM, 2010.
[28]
E. Meijer, M. M. Fokkinga, and R. Paterson. Functional programming with bananas, lenses, envelopes and barbed wire. In Functional Programming Languages and Computer Architecture, pages 124--144. Springer, 1991.
[29]
B. O'Sullivan. http://hackage.haskell.org/package/criterion.
[30]
S. Owre, J. M. Rushby, and N. Shankar. PVS: A prototype verification system. In International Conference on Automated Deduction, pages 748--752. Springer-Verlag, 1992.
[31]
L. C. Paulson. The foundation of a generic theorem prover. Journal of Automated Reasoning, 5 (3): 363--397, 1989.
[32]
S. Peyton Jones and A. L. M. Santos. A transformation-based optimiser for Haskell. Science of Computer Programming, 32 (1-3): 3--47, 1998.
[33]
S. Peyton Jones, A. Tolmach, and T. Hoare. Playing by the rules: rewriting as a practical optimisation technique in GHC. In Haskell Workshop, pages 203--233. ACM, 2001.
[34]
B. C. Pierce. Types and Programming Languages. MIT Press, 2002.
[35]
A. Rodriguez, J. Jeuring, P. Jansson, A. Gerdes, O. Kiselyov, and B. C. d. S. Oliveira. Comparing libraries for generic programming in Haskell. In Haskell Symposium, pages 111--122. ACM, 2008.
[36]
D. Sands. Higher-order expression procedures. In Partial evaluation and semantics-based program manipulation, pages 178--189. ACM, 1995.
[37]
A. Santos. Compilation by Transformation in Non-Strict Functional Languages. PhD thesis, University of Glasgow, 1995.
[38]
W. L. Scherlis. Expression procedures and program derivation. PhD thesis, Stanford University, 1980.
[39]
T. Sheard and S. Peyton Jones. Template metaprogramming for Haskell. In Haskell Workshop, pages 1--16. ACM, 2002.
[40]
M. Sulzmann, M. M. T. Chakravarty, S. Peyton Jones, and K. Donnelly. System F with type equality coercions. In Types in Language Design and Implementaion, pages 53--66. ACM, 2007.
[41]
M. Tullsen. PATH, A Program Transformation System for Haskell. PhD thesis, Yale University, 2002.
[42]
E. Visser. Program transformation with Stratego/XT: Rules, strategies, tools, and systems in StrategoXT-0.9. In Domain-Specific Program Generation, pages 216--238. Spinger, 2004.
[43]
E. Visser. A survey of strategies in rule-based program transformation systems. Journal of Symbolic Computation, 40 (1): 831--873, 2005.
[44]
E. Visser, Z. Benaissa, and A. Tolmach. Building program optimizers with rewriting strategies. In International Conference on Functional Programming, pages 13--26. ACM, 1998.
[45]
D. Vytiniotis, S. Peyton Jones, and J. P. Magalhães. Equality proofs and deferred type errors. In International Conference on Functional Programming. ACM, 2012.
[46]
S. Weirich, D. Vytiniotis, S. Peyton Jones, and S. Zdancewic. Generative type abstraction and type-level computation. In Principles of Programming Languages, pages 227--240. ACM, 2011a.
[47]
S. Weirich, B. A. Yorgey, and T. Sheard. Binders unbound. In International Conference on Functional Programming, pages 333--345. ACM, 2011b.
[48]
A. R. Yakushev, S. Holdermans, A. Löh, and J. Jeuring. Generic programming with fixed points for mutually recursive datatypes. In International Conference on Functional Programming, pages 233--244. ACM, 2009.
[49]
B. A. Yorgey, S. Weirich, J. Cretin, S. Peyton Jones, D. Vytiniotis, and J. P. Magalhães. Giving Haskell a promotion. In Types in Language Design and Implementation, pages 53--66. ACM, 2012.

Cited By

View all

Index Terms

  1. The HERMIT in the machine: a plugin for the interactive transformation of GHC core language programs

    Recommendations

    Comments

    Information & Contributors

    Information

    Published In

    cover image ACM Conferences
    Haskell '12: Proceedings of the 2012 Haskell Symposium
    September 2012
    168 pages
    ISBN:9781450315746
    DOI:10.1145/2364506
    • cover image ACM SIGPLAN Notices
      ACM SIGPLAN Notices  Volume 47, Issue 12
      Haskell '12
      December 2012
      157 pages
      ISSN:0362-1340
      EISSN:1558-1160
      DOI:10.1145/2430532
      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: 13 September 2012

    Permissions

    Request permissions for this article.

    Check for updates

    Author Tags

    1. dsls
    2. equational reasoning
    3. ghc
    4. optimization
    5. strategic programming

    Qualifiers

    • Research-article

    Conference

    ICFP'12
    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)4
    • Downloads (Last 6 weeks)0
    Reflects downloads up to 13 Jan 2025

    Other Metrics

    Citations

    Cited By

    View all
    • (2022)Coinduction inductively: mechanizing coinductive proofs in Liquid HaskellProceedings of the 15th ACM SIGPLAN International Haskell Symposium10.1145/3546189.3549922(1-12)Online publication date: 6-Sep-2022
    • (2019)Improving HaskellTrends in Functional Programming10.1007/978-3-030-18506-0_6(114-135)Online publication date: 24-Apr-2019
    • (2017)Staged generic programmingProceedings of the ACM on Programming Languages10.1145/31102731:ICFP(1-29)Online publication date: 29-Aug-2017
    • (2017)Compiling to categoriesProceedings of the ACM on Programming Languages10.1145/31102711:ICFP(1-27)Online publication date: 29-Aug-2017
    • (2017)Stream fusion, to completenessACM SIGPLAN Notices10.1145/3093333.300988052:1(285-299)Online publication date: 1-Jan-2017
    • (2017)Stream fusion, to completenessProceedings of the 44th ACM SIGPLAN Symposium on Principles of Programming Languages10.1145/3009837.3009880(285-299)Online publication date: 1-Jan-2017
    • (2015)Reasoning with the HERMIT: tool support for equational reasoning on GHC core programsACM SIGPLAN Notices10.1145/2887747.280430350:12(23-34)Online publication date: 30-Aug-2015
    • (2015)Profile-guided meta-programmingACM SIGPLAN Notices10.1145/2813885.273799050:6(403-412)Online publication date: 3-Jun-2015
    • (2015)Reasoning with the HERMIT: tool support for equational reasoning on GHC core programsProceedings of the 2015 ACM SIGPLAN Symposium on Haskell10.1145/2804302.2804303(23-34)Online publication date: 30-Aug-2015
    • (2015)Profile-guided meta-programmingProceedings of the 36th ACM SIGPLAN Conference on Programming Language Design and Implementation10.1145/2737924.2737990(403-412)Online publication date: 3-Jun-2015
    • Show More Cited By

    View Options

    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