Advertisement

Optimising Embedded DSLs Using Template Haskell

  • Sean Seefried
  • Manuel Chakravarty
  • Gabriele Keller
Part of the Lecture Notes in Computer Science book series (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.

Keywords

Type Information Functional Programming Call Graph Algebraic Transformation Abstract Syntax Tree 
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.

Preview

Unable to display preview. Download preview PDF.

Unable to display preview. Download preview PDF.

References

  1. 1.
    The Glasgow Haskell Compiler, http://haskell.org/ghc
  2. 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. 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)CrossRefGoogle Scholar
  4. 4.
    Elliott, C.: Functional Image Synthesis. In: Proceedings Bridges 2001, Mathematical Connections in Art, Music, and Science (2001)Google Scholar
  5. 5.
    Elliott, C., Finne, S., de Moor, O.: Compiling embedded languages. Journal of Functional Programming 13(3), 455–481 (2003)MATHCrossRefGoogle Scholar
  6. 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. 7.
    Hudak, P.: Building domain-specific embedded languages. ACM Computing Surveys (CSUR) 28(4es), 196 (1996)CrossRefGoogle Scholar
  8. 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. 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)CrossRefGoogle Scholar
  10. 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. 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)CrossRefGoogle Scholar
  12. 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. 13.
    Pang, A., Stewart, D., Seefried, S., Chakravarty, M.: Plugging Haskell In. To be published in Haskell Workshop (June 2004)Google Scholar
  14. 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. 15.
    Sage, M.: FranTk – a declarative GUI language for Haskell. ACM SIGPLAN Notices 35(9), 106–117 (2000)CrossRefGoogle Scholar
  16. 16.
    Sheard, T., Jones, S.P.: Template Meta-Programming for Haskell. ACM SIGPLAN Notices: PLI Workshops 37(12), 60–75 (2002)CrossRefGoogle Scholar
  17. 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. 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)CrossRefGoogle Scholar

Copyright information

© Springer-Verlag Berlin Heidelberg 2004

Authors and Affiliations

  • Sean Seefried
    • 1
  • Manuel Chakravarty
    • 1
  • Gabriele Keller
    • 1
  1. 1.PLC Research GroupThe University of New South Wales, Sydney, National ICT Australia, ERTOS 

Personalised recommendations