close
Skip to main content

A Shallow Embedded Type Safe Extendable DSL for the Arduino

  • Conference paper
  • First Online:
Trends in Functional Programming (TFP 2015)

Part of the book series: Lecture Notes in Computer Science ((LNTCS,volume 9547))

Included in the following conference series:

  • 592 Accesses

  • 6 Citations

Abstract

This paper extends our method to construct a shallow embedded domain specific language, DSL, embedded in a function programming language. We show how one can add functions and tasks that are typed by the type system of the functional host language.

The DSL is clearly separated from its host functional language to facilitate the compilation to small executables in C++. The type system of the host language verifies the types in the DSL, including the types and proper use of variables. The DSL is extendable by new language constructs and interpretations without breaking any existing code. The type system guarantees that everything used in a DSL program is properly defined. We apply these techniques for a DSL to program Arduino microprocessor systems from Clean. The long term goal is to incorporate these microprocessors in the iTask system.

This is a preview of subscription content, log in via an institution to check access.

Access this chapter

Subscribe and save

Springer+
from $39.99 /Month
  • Starting from 10 chapters or articles per month
  • Access and download chapters and articles from more than 300k books and 2,500 journals
  • Cancel anytime
View plans

Buy Now

Chapter
USD 29.95
Price excludes VAT (USA)
  • Available as PDF
  • Read on any device
  • Instant download
  • Own it forever
eBook
USD 34.99
Price excludes VAT (USA)
  • Available as EPUB and PDF
  • Read on any device
  • Instant download
  • Own it forever
Softcover Book
USD 44.99
Price excludes VAT (USA)
  • Compact, lightweight edition
  • Free shipping worldwide - view details

Tax calculation will be finalised at checkout

Purchases are for personal use only

Institutional subscriptions

Similar content being viewed by others

Notes

  1. 1.

    DSL = Domain Specific Language, also called DSEL for Domain Specific Embedded Language.

  2. 2.

    A better program anticipates the overflow of the clock in longs after 25 days.

  3. 3.

    Every W a can be replaced by , but W a is a convenient shortcut.

References

  1. Alimarine, A.: Generic Functional Programming: Conceptual Design, Implementation and Applications. UB Radboud University Nijmegen (2003)

    Google Scholar 

  2. arduino.cc website (2015). www.arduino.cc

  3. arduino.org website (2015). www.arduino.org

  4. Augustsson, L.: Making edsls fly (2012). http://vimeo.com/73223479

  5. Carette, J., Kiselyov, O., Shan, C.C.: Finally tagless, partially evaluated: tagless staged interpreters for simpler typed languages. J. Funct. Program. 19(5), 509–543 (2009)

    Article  MathSciNet  MATH  Google Scholar 

  6. Cheney, J., Hinze, R.: First-class phantom types. Technical report, Cornell University (2003)

    Google Scholar 

  7. Elliott, C., Finne, S., de Moor, O.: Compiling embedded languages. J. Funct. Program. 13(2), 455 (2003). Updated version of paper by the same name that appeared in SAIG2000 Proceedings. http://conal.net/papers/jfp-saig/

    Article  MATH  Google Scholar 

  8. Firmata protocol (2015). http://firmata.org/wiki/Main_Page, http://github.com/firmata/protocol

  9. Gibbons, J.: Functional programming for domain-specific languages. In: Zsók, V., Horváth, Z., Csató, L. (eds.) CEFP 2013. LNCS, vol. 8606, pp. 1–28. Springer, Heidelberg (2015)

    Google Scholar 

  10. Gibbons, J., Wu, N.: Folding domain-specific languages: deep and shallow embeddings (functional pearl). SIGPLAN Not. 49(9), 339–347 (2014)

    Article  MathSciNet  Google Scholar 

  11. Gill, A.: Domain-specific languages and code synthesis using haskell. Queue 12(4), 30:30–30:43 (2014)

    Google Scholar 

  12. hArduino.: package that allows haskell programs to control arduino boards using the Firmata protocol (2013). http://hackage.haskell.org/package/hArduino

  13. Hudak, P.: Modular domain specific languages and tools. In: Proceedings of the 5th International Conference on Software Reuse. ICSR 1998, p. 134. IEEE Computer Society, Washington DC (1998)

    Google Scholar 

  14. Johann, P., Ghani, N.: Foundations for structured programming with gadts. SIGPLAN Not. 43(1), 297–308 (2008)

    Article  MATH  Google Scholar 

  15. Koopman, P.: Functional semantics. In: Achten, P., Koopman, P. (eds.) The Beauty of Functional Code. LNCS, vol. 8106, pp. 60–78. Springer, Heidelberg (2013)

    Chapter  Google Scholar 

  16. Leijen, D., Meijer, E.: Domain specific embedded compilers. SIGPLAN Not. 35(1), 109–122 (1999)

    Article  Google Scholar 

  17. Lindberg, R.: fpr-arduino: Functional Reactive Programming for the Arduino (2015). http://github.com/frp-arduino

  18. Plasmeijer, R., Achten, P., Koopman, P.: iTasks: executable specifications of interactive work flow systems for the web. In: Hinze, R., Ramsey, N. (eds.) Proceedings of the ICFP 2007, pp. 141–152. ACM, Freiburg (2007)

    Google Scholar 

  19. Plasmeijer, R., Lijnse, B., Michels, S., Achten, P., Koopman, P.: Task-oriented programming in a pure functional language. In: Proceedings of the 14th Symposium on Principles and Practice of Declarative Programming. PPDP 2012, pp. 195–206. ACM, New York (2012)

    Google Scholar 

  20. Plasmeijer, R., van Eekelen, M.: Clean language report (version 2.1) (2002). http://clean.cs.ru.nl

  21. Schwaab, C., Pfeiffer, M., Brady, E.: Safety first: targeting embedded systems with full-spectrum dependent types, TFP 2015 Draft Proceedings (2015)

    Google Scholar 

Download references

Acknowledgement

We thank the reviewers for their valuable feedback.

Author information

Authors and Affiliations

Authors

Corresponding author

Correspondence to Pieter Koopman.

Editor information

Editors and Affiliations

Appendix

Appendix

The classes defining the core of ARDSL.

figure av

Rights and permissions

Reprints and permissions

Copyright information

© 2016 Springer International Publishing Switzerland

About this paper

Cite this paper

Koopman, P., Plasmeijer, R. (2016). A Shallow Embedded Type Safe Extendable DSL for the Arduino. In: Serrano, M., Hage, J. (eds) Trends in Functional Programming. TFP 2015. Lecture Notes in Computer Science(), vol 9547. Springer, Cham. https://doi.org/10.1007/978-3-319-39110-6_6

Download citation

Keywords

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.

Publish with us

Policies and ethics