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.
- F. L. Bauer, H. Ehler, A. Horsch, B. Moeller, H. Partsch, O. Paukner, and P. Pepper. The Munich Project CIP. Springer-Verlag, 1988. Google Scholar
Digital Library
- Y. Bertot and P. Castéran. Interactive Theorem Proving and Program Development. Springer, 2004. Google Scholar
Digital Library
- R. Bird and O. de Moor. Algebra of Programming. Prentice Hall, 1997. Google Scholar
Digital Library
- 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.Google Scholar
Cross Ref
- 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. Google Scholar
Digital Library
- C. M. Brown. Tool Support for Refactoring Haskell Programs. PhD thesis, University of Kent, 2008.Google Scholar
- A. Bundy, D. Basin, D. Hutter, and A. Ireland. Rippling: Meta-Level Guidance for Mathematical Reasoning. Cambridge University Press, 2005. Google Scholar
Digital Library
- R. M. Burstall and J. Darlington. A transformation system for developing recursive programs. Journal of the ACM, 24 (1): 44--67, 1977. Google Scholar
Digital Library
- D. Delahaye. A tactic language for the system Coq. In Logic for Programming and Automated Reasoning, pages 85--95. Springer, 2000. Google Scholar
Digital Library
- E. Dolstra. First class rules and generic traversals for program transformation languages. Technical report, Utrecht University, 2001.Google Scholar
- 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. Google Scholar
Digital Library
- GHC Team. The Glorious Glasgow Haskell Compilation System User's Guide, Version 7.4.1, 2012. URL http://www.haskell.org/ghc.Google Scholar
- A. Gill. Introducing the Haskell equational reasoning assistant. In Haskell Workshop, pages 108--109. ACM, 2006. Google Scholar
Digital Library
- A. Gill. A Haskell hosted DSL for writing transformation systems. In Domain-Specific Languages, pages 285--309. Springer, 2009. Google Scholar
Digital Library
- A. Gill and G. Hutton. The worker/wrapper transformation. Journal of Functional Programming, 19 (2): 227--251, 2009. Google Scholar
Digital Library
- 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.Google Scholar
- J. Harrison. Handbook of Practical Logic and Automated Reasoning. Cambridge University Press, 2009. Google Scholar
Digital Library
- R. Hinze. A new approach to generic functional programming. In Principles of Programming Languages, pages 119--132. ACM, 2000. Google Scholar
Digital Library
- R. Hughes. A novel representation of lists and its application to the function "reverse". Information Processing Letters, 22 (3): 141--144, 1986. Google Scholar
Digital Library
- 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.Google Scholar
- 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. Google Scholar
Digital Library
- 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. Google Scholar
Digital Library
- R. Lämmel and J. Visser. Typed combinators for generic traversal. In Practical Aspects of Declarative Programming, pages 137--154. Springer, 2002. Google Scholar
Digital Library
- R. Lämmel, S. Thompson, and M. Kaiser. Programming errors in traversal programs over structured data. Science of Computer Programming, 2013. To appear.Google Scholar
Digital Library
- H. Li and S. Thompson. Tool support for refactoring functional programs. In Partial evaluation and semantics-based program manipulation, pages 199--203. ACM, 2008. Google Scholar
Digital Library
- A. Löh. Exploring Generic Haskell. PhD thesis, Utrecht University, 2004.Google Scholar
- 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. Google Scholar
Digital Library
- 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. Google Scholar
Digital Library
- B. O'Sullivan. http://hackage.haskell.org/package/criterion.Google Scholar
- 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. Google Scholar
Digital Library
- L. C. Paulson. The foundation of a generic theorem prover. Journal of Automated Reasoning, 5 (3): 363--397, 1989. Google Scholar
Digital Library
- S. Peyton Jones and A. L. M. Santos. A transformation-based optimiser for Haskell. Science of Computer Programming, 32 (1-3): 3--47, 1998. Google Scholar
Digital Library
- 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.Google Scholar
- B. C. Pierce. Types and Programming Languages. MIT Press, 2002. Google Scholar
Digital Library
- 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. Google Scholar
Digital Library
- D. Sands. Higher-order expression procedures. In Partial evaluation and semantics-based program manipulation, pages 178--189. ACM, 1995. Google Scholar
Digital Library
- A. Santos. Compilation by Transformation in Non-Strict Functional Languages. PhD thesis, University of Glasgow, 1995.Google Scholar
- W. L. Scherlis. Expression procedures and program derivation. PhD thesis, Stanford University, 1980. Google Scholar
Digital Library
- T. Sheard and S. Peyton Jones. Template metaprogramming for Haskell. In Haskell Workshop, pages 1--16. ACM, 2002. Google Scholar
Digital Library
- 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. Google Scholar
Digital Library
- M. Tullsen. PATH, A Program Transformation System for Haskell. PhD thesis, Yale University, 2002. Google Scholar
Digital Library
- 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.Google Scholar
Cross Ref
- E. Visser. A survey of strategies in rule-based program transformation systems. Journal of Symbolic Computation, 40 (1): 831--873, 2005. Google Scholar
Digital Library
- E. Visser, Z. Benaissa, and A. Tolmach. Building program optimizers with rewriting strategies. In International Conference on Functional Programming, pages 13--26. ACM, 1998. Google Scholar
Digital Library
- D. Vytiniotis, S. Peyton Jones, and J. P. Magalhães. Equality proofs and deferred type errors. In International Conference on Functional Programming. ACM, 2012. Google Scholar
Digital Library
- 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. Google Scholar
Digital Library
- S. Weirich, B. A. Yorgey, and T. Sheard. Binders unbound. In International Conference on Functional Programming, pages 333--345. ACM, 2011b. Google Scholar
Digital Library
- 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. Google Scholar
Digital Library
- 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. Google Scholar
Digital Library
Index Terms
The HERMIT in the machine: a plugin for the interactive transformation of GHC core language programs
Recommendations
The HERMIT in the machine: a plugin for the interactive transformation of GHC core language programs
Haskell '12: Proceedings of the 2012 Haskell SymposiumThe 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-...
The HERMIT in the stream: fusing stream fusion's concatMap
PEPM '14: Proceedings of the ACM SIGPLAN 2014 Workshop on Partial Evaluation and Program ManipulationStream Fusion, a popular deforestation technique in the Haskell community, cannot fuse the concatMap combinator. This is a serious limitation, as concatMap represents computations on nested streams. The original implementation of Stream Fusion used the ...
Fusing a Transformation Language with an Open Compiler
Program transformation systems provide powerful analysis and transformation frameworks as well as concise languages for language processing, but instantiating them for every subject language is an arduous task, most often resulting in half-completed ...







Comments