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.
Access this chapter
Tax calculation will be finalised at checkout
Purchases are for personal use only
Preview
Unable to display preview. Download preview PDF.
References
The Glasgow Haskell Compiler, http://haskell.org/ghc
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
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)
Elliott, C.: Functional Image Synthesis. In: Proceedings Bridges 2001, Mathematical Connections in Art, Music, and Science (2001)
Elliott, C., Finne, S., de Moor, O.: Compiling embedded languages. Journal of Functional Programming 13(3), 455–481 (2003)
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)
Hudak, P.: Building domain-specific embedded languages. ACM Computing Surveys (CSUR) 28(4es), 196 (1996)
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)
Hudak, P., Makucevich, T., Gadde, S., Whong, B.: Haskore music notation - an algebra of music. Journal of Functional Programming 6(3), 465–483 (1996)
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)
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)
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
Pang, A., Stewart, D., Seefried, S., Chakravarty, M.: Plugging Haskell In. To be published in Haskell Workshop (June 2004)
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)
Sage, M.: FranTk – a declarative GUI language for Haskell. ACM SIGPLAN Notices 35(9), 106–117 (2000)
Sheard, T., Jones, S.P.: Template Meta-Programming for Haskell. ACM SIGPLAN Notices: PLI Workshops 37(12), 60–75 (2002)
Smith, B.C.: Reflection and Semantics in Lisp. In: Conf. Rec. 11th ACM Symp. on Principles of Programming Languages, pp. 23–35 (1984)
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)
Author information
Authors and Affiliations
Editor information
Editors and Affiliations
Rights 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