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.
Access this chapter
Tax calculation will be finalised at checkout
Purchases are for personal use only
Similar content being viewed by others
Notes
- 1.
DSL = Domain Specific Language, also called DSEL for Domain Specific Embedded Language.
- 2.
A better program anticipates the overflow of the clock in longs after 25Â days.
- 3.
Every W a can be replaced by
, but W a is a convenient shortcut.
References
Alimarine, A.: Generic Functional Programming: Conceptual Design, Implementation and Applications. UB Radboud University Nijmegen (2003)
arduino.cc website (2015). www.arduino.cc
arduino.org website (2015). www.arduino.org
Augustsson, L.: Making edsls fly (2012). http://vimeo.com/73223479
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)
Cheney, J., Hinze, R.: First-class phantom types. Technical report, Cornell University (2003)
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/
Firmata protocol (2015). http://firmata.org/wiki/Main_Page, http://github.com/firmata/protocol
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)
Gibbons, J., Wu, N.: Folding domain-specific languages: deep and shallow embeddings (functional pearl). SIGPLAN Not. 49(9), 339–347 (2014)
Gill, A.: Domain-specific languages and code synthesis using haskell. Queue 12(4), 30:30–30:43 (2014)
hArduino.: package that allows haskell programs to control arduino boards using the Firmata protocol (2013). http://hackage.haskell.org/package/hArduino
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)
Johann, P., Ghani, N.: Foundations for structured programming with gadts. SIGPLAN Not. 43(1), 297–308 (2008)
Koopman, P.: Functional semantics. In: Achten, P., Koopman, P. (eds.) The Beauty of Functional Code. LNCS, vol. 8106, pp. 60–78. Springer, Heidelberg (2013)
Leijen, D., Meijer, E.: Domain specific embedded compilers. SIGPLAN Not. 35(1), 109–122 (1999)
Lindberg, R.: fpr-arduino: Functional Reactive Programming for the Arduino (2015). http://github.com/frp-arduino
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)
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)
Plasmeijer, R., van Eekelen, M.: Clean language report (version 2.1) (2002). http://clean.cs.ru.nl
Schwaab, C., Pfeiffer, M., Brady, E.: Safety first: targeting embedded systems with full-spectrum dependent types, TFP 2015 Draft Proceedings (2015)
Acknowledgement
We thank the reviewers for their valuable feedback.
Author information
Authors and Affiliations
Corresponding author
Editor information
Editors and Affiliations
Appendix
Appendix
The classes defining the core of ARDSL.

Rights 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
DOI: https://doi.org/10.1007/978-3-319-39110-6_6
Published:
Publisher Name: Springer, Cham
Print ISBN: 978-3-319-39109-0
Online ISBN: 978-3-319-39110-6
eBook Packages: Computer ScienceComputer Science (R0)Springer Nature Proceedings Computer Science
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.