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 Proceedings of the ACM SIGPLAN Haskell Symposium, ser. Haskell ’12. ACM, 2012, pp. 1–12.



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.


  author = {Andrew Farmer and Andy Gill and Ed Komp and Neil Sculthorpe},
  title = {The {HERMIT} in the Machine: A Plugin for the Interactive Transformation of {GHC} Core Language Programs},
  booktitle = {Proceedings of the ACM SIGPLAN Haskell Symposium},
  series = {Haskell '12},
  year = {2012},
  isbn = {978-1-4503-1574-6},
  location = {Copenhagen, Denmark},
  pages = {1--12},
  doi = {10.1145/2364506.2364508},
  acmid = {2364508},
  publisher = {ACM},
  keywords = {{DSL}s, equational reasoning, {GHC}, optimization, strategic programming},