Preprocessing Eden with Template Haskell

  • Steffen Priebe
Conference paper
Part of the Lecture Notes in Computer Science book series (LNCS, volume 3676)


Extending a programming language by new language constructs often implies extending its compiler by additional machinery. To reduce the complex interweaving of compiler and extension implementations we present a simple and modular concept of lifting the often needed additional preprocessing out of the base compiler implementation. Avoiding the introduction of standalone tools, this preprocessor framework for extensions of Haskell is designed as a separate portable library of monadic preprocessing functions based on Template Haskell. Additional preprocessing passes expressed in this framework can then much easier be carried along the series of ever advancing base compiler versions. Taking Eden, a parallel programming extension of Haskell, as an example we show that besides achieving improved portability and reusability pass code sizes can be reduced considerably.


Abstract Syntax Functional Programming Abstract Syntax Tree Active Library State Monad 
These keywords were added by machine and not by the authors. This process is experimental and the keywords may be updated as the learning algorithm improves.


Unable to display preview. Download preview PDF.

Unable to display preview. Download preview PDF.


  1. 1.
    Peyton Jones, S., et al.: Haskell 1998: A Non-strict, Purely Functional Language (2003), See:
  2. 2.
    Czarnecki, K., et al.: Generative Programming and Active Libraries. In: Jazayeri, M., Musser, D.R., Loos, R.G.K. (eds.) Dagstuhl Seminar 1998. LNCS, vol. 1766, p. 25. Springer, Heidelberg (2000)CrossRefGoogle Scholar
  3. 3.
    Loogen, R., Ortega-Mallén, Y., Peña, R.: Parallel Functional Programming in Eden. Journal of Functional Programming, Special Issue on Functional Approaches to High-Performance Parallel Programming (2004) (to appear)Google Scholar
  4. 4.
    Peyton Jones, S., et al.: The Glorious Glasgow Haskell Compilation System, Version 6.4 (2005), Available at:
  5. 5.
    Berthold, J., Klusik, U., Loogen, R., Priebe, S., Weskamp, N.: High-level Process Control in Eden. In: Kosch, H., Böszörményi, L., Hellwagner, H. (eds.) Euro-Par 2003. LNCS, vol. 2790, pp. 732–741. Springer, Heidelberg (2003)CrossRefGoogle Scholar
  6. 6.
    Berthold, J.: Towards a generalised runtime environment for parallel haskells. In: Bubak, M., van Albada, G.D., Sloot, P.M.A., Dongarra, J. (eds.) ICCS 2004. LNCS, vol. 3038, pp. 297–305. Springer, Heidelberg (2004)CrossRefGoogle Scholar
  7. 7.
    Nordin, T., Peyton Jones, S.L.: Green card: a foreign-language interface for Haskell. In: Proceedings of the Haskell Workshop, Amsterdam, Netherlands (1997)Google Scholar
  8. 8.
    Reid, A.: Template Greencard. In: Proceedings of 15th International Workshop on the Implementation of Functional Languages (IFL 2003), Edinburgh (2003)Google Scholar
  9. 9.
    Sheard, T., Peyton Jones, S.: Template Meta-programming for Haskell. In: Haskell Workshop 2002. ACM Press, New York (2002)Google Scholar
  10. 10.
    Wadler, P.: Comprehending monads. In: Mathematical Structures in Computer Science, vol. 2, pp. 461–493 (1992)Google Scholar
  11. 11.
    Jones, M.P.: Functional Programming with Overloading and Higher-Order Polymorphism. In: Jeuring, J., Meijer, E. (eds.) AFP 1995. LNCS, vol. 925, pp. 97–136. Springer, Heidelberg (1995)Google Scholar
  12. 12.
    Klusik, U., Loogen, R., Priebe, S.: Controlling Parallelism and Data Distribution in Eden. In: Trends in Functional Programming (Selected papers of the Second Scottish Functional Programming Workshop), Intellect, vol. 2, pp. 53–64 (2000)Google Scholar
  13. 13.
    Trinder, P.W., Hammond, K., Loidl, H.W., Peyton Jones, S.L.: Algorithm + Strategy = Parallelism. In: Kluge, W. (ed.) Workshop on the Implementation of Functional Languages, Bonn, Germany, Universität Kiel (1996)Google Scholar
  14. 14.
    Backhouse, R., Jansson, P., Jeuring, J., Meertens, L.: Generic Programming – An Introduction. In: Swierstra, S.D., Henriques, P.R., Oliveira, J.N. (eds.) AFP 1998. LNCS, vol. 1608, pp. 28–115. Springer, Heidelberg (1999)CrossRefGoogle Scholar
  15. 15.
    Lynagh, I.: Template Haskell: A report from the field. Unpublished. Available from the author’s web page (2003)Google Scholar
  16. 16.
    Lynagh, I.: Unrolling and simplifying expressions with Template Haskell. Unpublished. Available from the author’s web page (2003)Google Scholar
  17. 17.
    Seefried, S., Chakravarty, M., Keller, G.: Optimising Embedded DSLs using Template Haskell. In: Karsai, G., Visser, E. (eds.) GPCE 2004. LNCS, vol. 3286, pp. 186–205. Springer, Heidelberg (2004)CrossRefGoogle Scholar
  18. 18.
    Peyton Jones, S., Tolmach, A., Hoare, T.: Playing by the Rules: Rewriting as a practical optimisation technique in GHC. In: Haskell Workshop (2001)Google Scholar
  19. 19.
    Tolmach, A., et al.: An External Representation for the GHC Core Language (Draft for GHC 5.02 documentation) (2001)Google Scholar
  20. 20.
    Veldhuizen, T., Gannon, D.: Active libraries: Rethinking the roles of compilers and libraries. In: Proceedings of the SIAM Workshop on Object Oriented Methods for Interoperable Scientific and Engineering Computing, OO 1998 (1998)Google Scholar
  21. 21.
    Norell, U., Jansson, P.: Prototyping Generic Programming in Template Haskell. In: Kozen, D. (ed.) MPC 2004. LNCS, vol. 3125, pp. 314–333. Springer, Heidelberg (2004)CrossRefGoogle Scholar
  22. 22.
    Lämmel, R., Peyton Jones, S.: Scrap your Boilerplate: A Practical Design Pattern for Generic Programming. In: Proceedings of ACM Sigplan Types in Language Design and Implementation, TLDI (2003)Google Scholar

Copyright information

© Springer-Verlag Berlin Heidelberg 2005

Authors and Affiliations

  • Steffen Priebe
    • 1
  1. 1.Fachbereich Mathematik und InformatikPhilipps-Universität MarburgMarburgGermany

Personalised recommendations