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.
- 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 Scholar
Digital Library
- 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 Scholar
Cross Ref
- 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 Scholar
Digital Library
- Conal Elliott. 2015. (2015). https://github.com/conal/lambda-cccGoogle Scholar
- Conal Elliott. 2015. (2015). https://github.com/conal/ talk-2015-haskell-to-hardwareGoogle Scholar
- Conal Elliott. 2016. (2016). https://github.com/conal/reification-rulesGoogle Scholar
- Conal Elliott. 2017. Compiling to categories. Proc. ACM Program. Lang. 1, ICFP, Article 48 (Sept. 2017), 24 pages. DOI: Google Scholar
Digital Library
- 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 Scholar
Digital Library
- Levent Erkok. 2014. Hackage package hArduino-0.9. (2014).Google Scholar
- 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 Scholar
Digital Library
- GHC Team. 2016. Glasgow Haskell Compiler User’s Guide, Version 8.0.1. https://downloads.haskell.org/~ghc/latest/docs/html/users_guide/Google Scholar
- 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 Scholar
Digital Library
- A Gill and G Hutton. 2009. The worker/wrapper transformation. Journal of Functional Programming (2009).Google Scholar
- Andy Gill and Ryan Scott. 2015. (2015). https://github.com/ku-fpg/ blank-canvasGoogle Scholar
- 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 Scholar
Digital Library
- Mark Grebe. 2017. (2017). https://github.com/ku-fpg/haskinoGoogle Scholar
- Mark Grebe and Andy Gill. 2016. Haskino: A Remote Monad for Programming the Arduino. In Practical Aspects of Declarative Languages. Springer, 153–168. Google Scholar
Cross Ref
- Mark Grebe and Andy Gill. 2017. Threading the Arduino with Haskell. In Post-Proceedings of Trends in Functional Programming.Google Scholar
- C. A. Hoare. 1972. Proof of Correctness of Data Representations. Acta Informatica 1, 4 (Dec. 1972), 271–281. Google Scholar
Digital Library
- SLP Jones and J Launchbury. 1991. Unboxed values as first class citizens in a non-strict functional language. Conference on Functional Programming (1991).Google Scholar
Cross Ref
- 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 Scholar
- 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 Scholar
Digital Library
- 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 Scholar
Digital Library
- 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 Scholar
- 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 Scholar
Digital Library
- 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 Scholar
Digital Library
- 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 Scholar
Digital Library
- Josef Svenningsson and Emil Axelsson. 2013. Combining deep and shallow embedding for EDSL. In Trends in Functional Programming. Springer, 21–36. Google Scholar
Digital Library
Index Terms
Rewriting a shallow DSL using a GHC compiler extension
Recommendations
Rewriting a shallow DSL using a GHC compiler extension
GPCE 2017: Proceedings of the 16th ACM SIGPLAN International Conference on Generative Programming: Concepts and ExperiencesEmbedded 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 ...
An llVM backend for GHC
Haskell '10: Proceedings of the third ACM Haskell symposium on HaskellIn the presence of ever-changing computer architectures, high-quality optimising compiler backends are moving targets that require specialist knowledge and sophisticated algorithms. In this paper, we explore a new backend for the Glasgow Haskell ...
An llVM backend for GHC
HASKELL '10In the presence of ever-changing computer architectures, high-quality optimising compiler backends are moving targets that require specialist knowledge and sophisticated algorithms. In this paper, we explore a new backend for the Glasgow Haskell ...







Comments