Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
skip to main content
article

Rewriting a shallow DSL using a GHC compiler extension

Published: 23 October 2017 Publication History

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.
[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.
[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.
[4]
Conal Elliott. 2015. (2015). https://github.com/conal/lambda-ccc
[5]
Conal Elliott. 2015. (2015). https://github.com/conal/ talk-2015-haskell-to-hardware
[6]
Conal Elliott. 2016. (2016). https://github.com/conal/reification-rules
[7]
Conal Elliott. 2017. Compiling to categories. Proc. ACM Program. Lang. 1, ICFP, Article 48 (Sept. 2017), 24 pages.
[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.
[9]
Levent Erkok. 2014. Hackage package hArduino-0.9. (2014).
[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.
[11]
GHC Team. 2016. Glasgow Haskell Compiler User’s Guide, Version 8.0.1. https://downloads.haskell.org/~ghc/latest/docs/html/users_guide/
[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.
[13]
A Gill and G Hutton. 2009. The worker/wrapper transformation. Journal of Functional Programming (2009).
[14]
Andy Gill and Ryan Scott. 2015. (2015). https://github.com/ku-fpg/ blank-canvas
[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.
[16]
Mark Grebe. 2017. (2017). https://github.com/ku-fpg/haskino
[17]
Mark Grebe and Andy Gill. 2016. Haskino: A Remote Monad for Programming the Arduino. In Practical Aspects of Declarative Languages. Springer, 153–168.
[18]
Mark Grebe and Andy Gill. 2017. Threading the Arduino with Haskell. In Post-Proceedings of Trends in Functional Programming.
[19]
C. A. Hoare. 1972. Proof of Correctness of Data Representations. Acta Informatica 1, 4 (Dec. 1972), 271–281.
[20]
SLP Jones and J Launchbury. 1991. Unboxed values as first class citizens in a non-strict functional language. Conference on Functional Programming (1991).
[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.
[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.
[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.
[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.
[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.
[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.
[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.
[28]
Josef Svenningsson and Emil Axelsson. 2013. Combining deep and shallow embedding for EDSL. In Trends in Functional Programming. Springer, 21–36.

Recommendations

Comments

Information & Contributors

Information

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
Permission to make digital or hard copies of all or part of this work for personal or classroom use is granted without fee provided that copies are not made or distributed for profit or commercial advantage and that copies bear this notice and the full citation on the first page. Copyrights for components of this work owned by others than ACM must be honored. Abstracting with credit is permitted. To copy otherwise, or republish, to post on servers or to redistribute to lists, requires prior specific permission and/or a fee. Request permissions from [email protected]

Publisher

Association for Computing Machinery

New York, NY, United States

Publication History

Published: 23 October 2017
Published in SIGPLAN Volume 52, Issue 12

Check for updates

Author Tags

  1. Arduino
  2. EDSL
  3. GHC
  4. Haskell
  5. Transformations

Qualifiers

  • Article

Contributors

Other Metrics

Bibliometrics & Citations

Bibliometrics

Article Metrics

  • Downloads (Last 12 months)9
  • Downloads (Last 6 weeks)5
Reflects downloads up to 15 Oct 2024

Other Metrics

Citations

View Options

Get Access

Login options

View options

PDF

View or Download as a PDF file.

PDF

eReader

View online with eReader.

eReader

Media

Figures

Other

Tables

Share

Share

Share this Publication link

Share on social media