skip to main content
article

Rewriting a shallow DSL using a GHC compiler extension

Published:23 October 2017Publication History
Skip Abstract Section

Abstract

Embedded Domain Specific Languages are a powerful tool for developing customized languages to fit specific problem domains. Shallow EDSLs allow a programmer to program using many of the features of a host language and its syntax, but sacrifice performance. Deep EDSLs provide better performance and flexibility, through the ability to manipulate the abstract syntax tree of the DSL program, but sacrifice syntactical similarity to the host language. Using Haskino, an EDSL designed for small embedded systems based on the Arduino line of microcontrollers, and a compiler plugin for the Haskell GHC compiler, we show a method for combining the best aspects of shallow and deep EDSLs. The programmer is able to write in the shallow EDSL, and have it automatically transformed into the deep EDSL. This allows the EDSL user to benefit from powerful aspects of the host language, Haskell, while meeting the demanding resource constraints of the small embedded processing environment.

References

  1. Emil Axelsson, Koen Claessen, Gergely Dévai, Zoltán Horváth, Karin Keijzer, Bo Lyckegård, Anders Persson, Mary Sheeran, Josef Svenningsson, and Andras Vajdax. 2010. Feldspar: A domain specific language for digital signal processing algorithms.. In MEMOCODE’10. 169–178. Google ScholarGoogle ScholarDigital LibraryDigital Library
  2. Emil Axelsson, Koen Claessen, Mary Sheeran, Josef Svenningsson, David Engdal, and Anders Persson. 2011. The design and implementation of Feldspar. In Implementation and Application of Functional Languages . Springer, 121–136. Google ScholarGoogle ScholarCross RefCross Ref
  3. Kevin J. Brown, Arvind K. Sujeeth, Hyouk Joong Lee, Tiark Rompf, Hassan Chafi, Martin Odersky, and Kunle Olukotun. 2011. A Heterogeneous Parallel Framework for Domain-Specific Languages. In Proceedings of the 2011 International Conference on Parallel Architectures and Compilation Techniques (PACT ’11) . IEEE Computer Society, Washington, DC, USA, 89–100. DOI: Google ScholarGoogle ScholarDigital LibraryDigital Library
  4. Conal Elliott. 2015. (2015). https://github.com/conal/lambda-cccGoogle ScholarGoogle Scholar
  5. Conal Elliott. 2015. (2015). https://github.com/conal/ talk-2015-haskell-to-hardwareGoogle ScholarGoogle Scholar
  6. Conal Elliott. 2016. (2016). https://github.com/conal/reification-rulesGoogle ScholarGoogle Scholar
  7. Conal Elliott. 2017. Compiling to categories. Proc. ACM Program. Lang. 1, ICFP, Article 48 (Sept. 2017), 24 pages. DOI: Google ScholarGoogle ScholarDigital LibraryDigital Library
  8. Trevor Elliott, Lee Pike, Simon Winwood, Pat Hickey, James Bielman, Jamey Sharp, Eric Seidel, and John Launchbury. 2015. Guilt free ivory. In Proceedings of the 8th ACM SIGPLAN Symposium on Haskell. ACM, 189–200. Google ScholarGoogle ScholarDigital LibraryDigital Library
  9. Levent Erkok. 2014. Hackage package hArduino-0.9. (2014).Google ScholarGoogle Scholar
  10. Andrew Farmer, Neil Sculthorpe, and Andy Gill. 2015. Reasoning with the HERMIT: tool support for equational reasoning on GHC core programs. In Proceedings of the 8th ACM SIGPLAN Symposium on Haskell . ACM, 23–34. Google ScholarGoogle ScholarDigital LibraryDigital Library
  11. GHC Team. 2016. Glasgow Haskell Compiler User’s Guide, Version 8.0.1. https://downloads.haskell.org/~ghc/latest/docs/html/users_guide/Google ScholarGoogle Scholar
  12. Andy Gill, Tristan Bull, Andrew Farmer, Garrin Kimmell, and Ed Komp. 2013. Types and Associated Type Families for Hardware Simulation and Synthesis: The Internals and Externals of Kansas Lava. HigherOrder and Symbolic Computation (2013), 1–20. DOI: Google ScholarGoogle ScholarDigital LibraryDigital Library
  13. A Gill and G Hutton. 2009. The worker/wrapper transformation. Journal of Functional Programming (2009).Google ScholarGoogle Scholar
  14. Andy Gill and Ryan Scott. 2015. (2015). https://github.com/ku-fpg/ blank-canvasGoogle ScholarGoogle Scholar
  15. Andy Gill, Neil Sculthorpe, Justin Dawson, Aleksander Eskilson, Andrew Farmer, Mark Grebe, Jeffrey Rosenbluth, Ryan Scott, and James Stanton. 2015. The remote monad design pattern. In Proceedings of the 8th ACM SIGPLAN Symposium on Haskell . ACM, 59–70. Google ScholarGoogle ScholarDigital LibraryDigital Library
  16. Mark Grebe. 2017. (2017). https://github.com/ku-fpg/haskinoGoogle ScholarGoogle Scholar
  17. Mark Grebe and Andy Gill. 2016. Haskino: A Remote Monad for Programming the Arduino. In Practical Aspects of Declarative Languages. Springer, 153–168. Google ScholarGoogle ScholarCross RefCross Ref
  18. Mark Grebe and Andy Gill. 2017. Threading the Arduino with Haskell. In Post-Proceedings of Trends in Functional Programming.Google ScholarGoogle Scholar
  19. C. A. Hoare. 1972. Proof of Correctness of Data Representations. Acta Informatica 1, 4 (Dec. 1972), 271–281. Google ScholarGoogle ScholarDigital LibraryDigital Library
  20. SLP Jones and J Launchbury. 1991. Unboxed values as first class citizens in a non-strict functional language. Conference on Functional Programming (1991).Google ScholarGoogle ScholarCross RefCross Ref
  21. Simon Peyton Jones, Andrew Tolmach, and Tony Hoare. 2001. Playing by the rules: rewriting as a practical optimisation technique in GHC. In Haskell workshop 1. 203–233.Google ScholarGoogle Scholar
  22. Vojin Jovanovic, Amir Shaikhha, Sandro Stucki, Vladimir Nikolaev, Christoph Koch, and Martin Odersky. 2014. Yin-yang: Concealing the Deep Embedding of DSLs. In Proceedings of the 2014 International Conference on Generative Programming: Concepts and Experiences (GPCE 2014) . ACM, New York, NY, USA, 73–82. DOI: Google ScholarGoogle ScholarDigital LibraryDigital Library
  23. Simon Marlow, Louis Brandy, Jonathan Coens, and Jon Purdy. 2014. There is No Fork: An Abstraction for Efficient, Concurrent, and Concise Data Access. In International Conference on Functional Programming. ACM, 325–337. Google ScholarGoogle ScholarDigital LibraryDigital Library
  24. Simon Peyton Jones and André L. M. Santos. 1998. A transformationbased optimiser for Haskell. Science of Computer Programming 32, 1–3 (1998), 3–47.Google ScholarGoogle Scholar
  25. Tiark Rompf and Martin Odersky. 2010. Lightweight Modular Staging: A Pragmatic Approach to Runtime Code Generation and Compiled DSLs. In Proceedings of the Ninth International Conference on Generative Programming and Component Engineering (GPCE ’10) . ACM, New York, NY, USA, 127–136. DOI: Google ScholarGoogle ScholarDigital LibraryDigital Library
  26. Maximilian Scherr and Shigeru Chiba. 2014. Implicit Staging of EDSL Expressions: A Bridge Between Shallow and Deep Embedding. In Proceedings of the 28th European Conference on ECOOP 2014 — Object-Oriented Programming - Volume 8586 . Springer-Verlag New York, Inc., New York, NY, USA, 385–410. DOI: Google ScholarGoogle ScholarDigital LibraryDigital Library
  27. Arvind K. Sujeeth, Austin Gibbons, Kevin J. Brown, HyoukJoong Lee, Tiark Rompf, Martin Odersky, and Kunle Olukotun. 2013. Forge: Generating a High Performance DSL Implementation from a Declarative Specification. In Proceedings of the 12th International Conference on Generative Programming: Concepts & Experiences (GPCE ’13) . ACM, New York, NY, USA, 145–154. DOI: Google ScholarGoogle ScholarDigital LibraryDigital Library
  28. Josef Svenningsson and Emil Axelsson. 2013. Combining deep and shallow embedding for EDSL. In Trends in Functional Programming. Springer, 21–36. Google ScholarGoogle ScholarDigital LibraryDigital Library

Index Terms

  1. Rewriting a shallow DSL using a GHC compiler extension

        Recommendations

        Comments

        Login options

        Check if you have access through your login credentials or your institution to get full access on this article.

        Sign in

        Full Access

        • Published in

          cover image ACM SIGPLAN Notices
          ACM SIGPLAN Notices  Volume 52, Issue 12
          GPCE '17
          December 2017
          258 pages
          ISSN:0362-1340
          EISSN:1558-1160
          DOI:10.1145/3170492
          Issue’s Table of Contents
          • cover image ACM Conferences
            GPCE 2017: Proceedings of the 16th ACM SIGPLAN International Conference on Generative Programming: Concepts and Experiences
            October 2017
            258 pages
            ISBN:9781450355247
            DOI:10.1145/3136040

          Copyright © 2017 ACM

          Publisher

          Association for Computing Machinery

          New York, NY, United States

          Publication History

          • Published: 23 October 2017

          Check for updates

          Qualifiers

          • article

        PDF Format

        View or Download as a PDF file.

        PDF

        eReader

        View online with eReader.

        eReader
        About Cookies On This Site

        We use cookies to ensure that we give you the best experience on our website.

        Learn more

        Got it!