Skip to main content

Optimising Embedded DSLs Using Template Haskell

  • Conference paper
Generative Programming and Component Engineering (GPCE 2004)

Part of the book series: Lecture Notes in Computer Science ((LNCS,volume 3286))

Abstract

Embedded domain specific languages (EDSLs) provide a specialised language for a particular application area while harnessing the infrastructure of an existing general purpose programming language. The reduction in implementation costs that results from this approach comes at a price: the EDSL often compiles to inefficient code since the host language’s compiler only optimises at the level of host language constructs. The paper presents an approach to solving this problem based on compile-time meta-programming which retains the simplicity of the embedded approach. We use PanTHeon, our implementation of an existing EDSL for image synthesis to demonstrate the benefits and drawbacks of this approach. Furthermore, we suggest potential improvements to Template Haskell, the meta-programming framework we are using, which would greatly improve its applicability to this kind of task.

This is a preview of subscription content, log in via an institution to check access.

Access this chapter

Chapter
USD 29.95
Price excludes VAT (USA)
  • Available as PDF
  • Read on any device
  • Instant download
  • Own it forever
eBook
USD 39.99
Price excludes VAT (USA)
  • Available as PDF
  • Read on any device
  • Instant download
  • Own it forever
Softcover Book
USD 54.99
Price excludes VAT (USA)
  • Compact, lightweight edition
  • Dispatched in 3 to 5 business days
  • Free shipping worldwide - see info

Tax calculation will be finalised at checkout

Purchases are for personal use only

Institutional subscriptions

Preview

Unable to display preview. Download preview PDF.

Unable to display preview. Download preview PDF.

References

  1. The Glasgow Haskell Compiler, http://haskell.org/ghc

  2. Czarnecki, K., O’Donnell, J., Striegnitz, J., Taha, W.: DSL Implementation in MetaOCaml, Template Haskell, and C++ (2003), http://www.cs.rice.edu/~taha/publications.html

  3. Elliott, C.: Functional implementations of continuous modeled animation. In: Palamidessi, C., Meinke, K., Glaser, H. (eds.) ALP 1998 and PLILP 1998. LNCS, vol. 1490, p. 284. Springer, Heidelberg (1998)

    Chapter  Google Scholar 

  4. Elliott, C.: Functional Image Synthesis. In: Proceedings Bridges 2001, Mathematical Connections in Art, Music, and Science (2001)

    Google Scholar 

  5. Elliott, C., Finne, S., de Moor, O.: Compiling embedded languages. Journal of Functional Programming 13(3), 455–481 (2003)

    Article  MATH  Google Scholar 

  6. Friedman, D.P., Wand, M.: Reification: Reflection without Metaphysics. In: Proceedings of the 1984 ACM Symposium on LISP and functional programming, pp. 348–355 (1984)

    Google Scholar 

  7. Hudak, P.: Building domain-specific embedded languages. ACM Computing Surveys (CSUR) 28(4es), 196 (1996)

    Article  Google Scholar 

  8. Hudak, P.: Modular domain specific languages and tools. In: Devanbu, P., Poulin, J. (eds.) Proceedings: Fifth International Conference on Software Reuse, pp. 134–142. IEEE Computer Society Press, Los Alamitos (1998)

    Google Scholar 

  9. Hudak, P., Makucevich, T., Gadde, S., Whong, B.: Haskore music notation - an algebra of music. Journal of Functional Programming 6(3), 465–483 (1996)

    Article  Google Scholar 

  10. Jones, S.P., Tolmach, A., Hoare, T.: Playing by the Rules: Rewriting as a practical optimisation technique in GHC. In: International Conference on Functional Programming (ICFP 2001). Haskell Workshop (September 2001)

    Google Scholar 

  11. Lämmel, R., Jones, S.P.: Scrap your boilerplate: a practical design pattern for generic programming. ACM SIGPLAN Notices 38(3), 26–37 (2003); Proc. of the ACM SIGPLAN Workshop on Types in Language Design and Implementation (TLDI 2003)

    Article  Google Scholar 

  12. Lynagh, I.: Unrolling and simplifying expressions with Template Haskell (May 2003), http://web.comlab.ox.ac.uk/oucl/work/ian.lynagh/papers/Unrolling_and_Simplifying_Expressions_with_Template_Haskell.ps

  13. Pang, A., Stewart, D., Seefried, S., Chakravarty, M.: Plugging Haskell In. To be published in Haskell Workshop (June 2004)

    Google Scholar 

  14. Robinson, A.D.: The Impact of Economics on Compiler Optimization. In: Proceedings of the ACM 2001 Java Grande Conference, Standford, pp. 1–10 (June 2001)

    Google Scholar 

  15. Sage, M.: FranTk – a declarative GUI language for Haskell. ACM SIGPLAN Notices 35(9), 106–117 (2000)

    Article  Google Scholar 

  16. Sheard, T., Jones, S.P.: Template Meta-Programming for Haskell. ACM SIGPLAN Notices: PLI Workshops 37(12), 60–75 (2002)

    Article  Google Scholar 

  17. Smith, B.C.: Reflection and Semantics in Lisp. In: Conf. Rec. 11th ACM Symp. on Principles of Programming Languages, pp. 23–35 (1984)

    Google Scholar 

  18. Wallace, M., Runciman, C.: Haskell and XML: Generic combinators or type-based translation? In: Proceedings of the Fourth ACM SIGPLAN International Conference on Functional Programming (ICFP 1999), 27-29, 1999, vol. 34-9, pp. 148–159. ACM Press, New York (1999)

    Chapter  Google Scholar 

Download references

Author information

Authors and Affiliations

Authors

Editor information

Editors and Affiliations

Rights and permissions

Reprints and permissions

Copyright information

© 2004 Springer-Verlag Berlin Heidelberg

About this paper

Cite this paper

Seefried, S., Chakravarty, M., Keller, G. (2004). Optimising Embedded DSLs Using Template Haskell. In: Karsai, G., Visser, E. (eds) Generative Programming and Component Engineering. GPCE 2004. Lecture Notes in Computer Science, vol 3286. Springer, Berlin, Heidelberg. https://doi.org/10.1007/978-3-540-30175-2_10

Download citation

  • DOI: https://doi.org/10.1007/978-3-540-30175-2_10

  • Publisher Name: Springer, Berlin, Heidelberg

  • Print ISBN: 978-3-540-23580-4

  • Online ISBN: 978-3-540-30175-2

  • eBook Packages: Springer Book Archive

Publish with us

Policies and ethics