Abstract
The Internet of Things, IoT, brings us large amounts of connected computing devices that are equipped with dedicated sensors and actuators. These computing devices are typically driven by a cheap microprocessor system with a relatively slow processor and a very limited amount of memory. Due to the special input-output capabilities of IoT devices and their connections it is very attractive to execute (parts of) programs on these microcomputers.
Task-oriented programming, as introduced in the iTask framework, offers a very convenient abstraction level to construct distributed programs at a high level of abstraction. The task concept basically introduces lightweight threads. Tasks can be composed to more powerful tasks by a flexible set of combinators. These tasks can communicate with each other via shared data sources and inspect intermediate task values of other tasks.
The IoT devices considered here are far from powerful enough to execute programs made within the standard iTask system. To facilitate the execution of simple tasks using the special capabilities of the IoT devices from the iTask environment, we introduce a type-safe multi-view extendable domain-specific language to specify tasks for IoT devices. This domain specific language is embedded in the iTask system to facilitate the integration of both systems, but those systems are very useful on their own.
Access this chapter
Tax calculation will be finalised at checkout
Purchases are for personal use only
Similar content being viewed by others
References
Ada, L.: adafruit/DHT-sensor-library (2017). https://github.com/adafruit/DHT-sensor-library
Arduino.cc: (2015). https://www.arduino.cc
Arduino.cc: Arduino LiquidCrystal Library (2015). https://www.arduino.cc/en/Reference/LiquidCrystal
Arduino.cc: Arduino NewPing Library (2015). http://playground.arduino.cc/Code/NewPing
Arduino.cc: Arduino Servo Library (2015). https://www.arduino.cc/en/Reference/Servo
Arduino.org (2015). http://www.arduino.org/
Carette, J., Kiselyov, O., Shan, C.: Finally tagless, partially evaluated: tagless staged interpreters for simpler typed languages. J. Funct. Program. 19(5), 509–543 (2009). https://doi.org/10.1017/S0956796809007205
D-Robotics: DHT11 humidity & temperature sensor (2010). http://www.micro4you.com/files/sensor/DHT11.pdf
Dagand, P.E., Baumann, A., Roscoe, T.: Filet-o-fish: practical and dependable domain-specific languages for OS development. SIGOPS Oper. Syst. Rev. 43(4), 35–39 (2010). https://doi.org/10.1145/1713254.1713263
Damas, L., Milner, R.: Principal type-schemes for functional programs. In: Proceedings of the 9th ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages, POPL 1982, pp. 207–212. ACM, New York (1982). https://doi.org/10.1145/582153.582176
Danvy, O., Nielsen, L.R.: Defunctionalization at work. In: Proceedings of the 3rd ACM SIGPLAN International Conference on Principles and Practice of Declarative Programming, PPDP 2001, pp. 162–174. ACM, New York (2001). https://doi.org/10.1145/773184.773202
Erkok, L.: hArduino (2014). https://hackage.haskell.org/package/hArduino
Feeley, M., Miller, J.S., Rozas, G.J., Wilson, J.A.: Compiling higher-order languages into fully tail-recursive portable C. Technical report (1997)
Fowler, M.: Domain Specific Languages, 1st edn. Addison-Wesley Professional, Boston (2010)
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, Cham (2015). https://doi.org/10.1007/978-3-319-15940-9_1
Hoefs, J.: Firmata protocol (2014). http://firmata.org/wiki/Main_Page
Hudak, P.: Building domain-specific embedded languages. ACM Comput. Surv. 28(4es) (1996). https://doi.org/10.1145/242224.242477
Ierusalimschy, R., de Figueiredo, L.H., Filho, W.C.: Lua - an extensible extension language. Softw. Pract. Exper. 26(6), 635–652 (1996)
Ierusalimschy, R., de Figueiredo, L.H., Celes, W.: Lua 5.1 Reference Manual (2006). Lua.org
Jansen, J.M.: Programming in the \(\lambda \)-calculus: from Church to Scott and back. In: Achten, P., Koopman, P. (eds.) The Beauty of Functional Code. LNCS, vol. 8106, pp. 168–180. Springer, Heidelberg (2013). https://doi.org/10.1007/978-3-642-40355-2_12
Jansen, J.M., Koopman, P., Plasmeijer, R.: From interpretation to compilation. In: Horváth, Z., Plasmeijer, R., Soós, A., Zsók, V. (eds.) CEFP 2007. LNCS, vol. 5161, pp. 286–301. Springer, Heidelberg (2008). https://doi.org/10.1007/978-3-540-88059-2_8
Johann, P., Ghani, N.: Foundations for structured programming with GADTs. SIGPLAN Not. 43(1), 297–308 (2008)
Jones, M.P., Diatchki, I.S.: Language and program design for functional dependencies. In: Proceedings of the First ACM SIGPLAN Symposium on Haskell, Haskell 2008, pp. 87–98. ACM, New York (2008). https://doi.org/10.1145/1411286.1411298
Jones, N.D., Gomard, C.K., Sestoft, P.: Partial Evaluation and Automatic Program Generation. Prentice-Hall, Inc., Upper Saddle River (1993)
Kameyama, Y., Kiselyov, O., Shan, C.: Combinators for impure yet hygienic code generation. In: Proceedings of the ACM SIGPLAN 2014 Workshop on Partial Evaluation and Program Manipulation, pp. 3–14, PEPM 2014. ACM, New York (2014). https://doi.org/10.1145/2543728.2543740
Koopman, P., Plasmeijer, R.: A shallow embedded type safe extendable DSL for the Arduino. In: Serrano, M., Hage, J. (eds.) TFP 2015. LNCS, vol. 9547, pp. 104–123. Springer, Cham (2016). https://doi.org/10.1007/978-3-319-39110-6_6
Lämmel, R., Ostermann, K.: Software extension and integration with type classes. In: Proceedings of the 5th International Conference on Generative Programming and Component Engineering, GPCE 2006, pp. 161–170. ACM, New York (2006). https://doi.org/10.1145/1173706.1173732
Lindberg, R.: frp-arduino (2015). https://github.com/frp-arduino/frp-arduino#contributing
Nielson, H.R., Nielson, F.: Semantics with Applications: A Formal Introduction. Wiley, New York (1992)
Peyton Jones, S.L.: The Implementation of Functional Programming Languages. Prentice-Hall International Series in Computer Science. Prentice-Hall, Inc., Upper Saddle River (1987)
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). https://doi.org/10.1145/2370776.2370801
Plasmeijer, R., van Eekelen, M., van Groningen, J.: Clean language report (version 2.2) (2011). http://clean.cs.ru.nl/Documentation
Raspberrypi.org: Pi zero description (2015). https://www.raspberrypi.org/products/pi-zero/
Reynolds, J.C.: Definitional interpreters for higher-order programming languages. In: Proceedings of the ACM Annual Conference, ACM 1972, vol. 2, pp. 717–740. ACM, New York (1972). https://doi.org/10.1145/800194.805852
Suchocki, R., Kalvala, S.: MicroScheme: functional programming for the Arduino. In: Scheme Workshop (2014)
Sumii, E.: MinCaml: a simple and efficient compiler for a minimal functional language. In: Proceedings of the 2005 Workshop on Functional and Declarative Programming in Education, FDPE 2005, pp. 27–38. ACM, New York (2005). https://doi.org/10.1145/1085114.1085122
visualmicro.com: Debugging tutorial (2015). http://www.visualmicro.com/page/User-Guide.aspx?doc=Debugging-Walkthrough-Start.html
Wadler, P.: The expression problem (1998). http://www.daimi.au.dk/~madst/tool/papers/expression.txt
Williams, G.: The espruino project (2015). http://www.espruino.com/
Acknowledgements
The authors thank Ralf Hinze and Peter Achten from the Radboud University for inspiring discussions about the architecture of the DSL used. Special thanks to the anonymous referees for their feedback on the draft version of this paper.
Author information
Authors and Affiliations
Corresponding author
Editor information
Editors and Affiliations
A The Function
A The Function
For completeness, this appendix contains the complete function discussed in Sect. 5.
Rights and permissions
Copyright information
© 2019 Springer Nature Switzerland AG
About this chapter
Cite this chapter
Koopman, P., Plasmeijer, R. (2019). Type-Safe Functions and Tasks in a Shallow Embedded DSL for Microprocessors. In: Zsók, V., Porkoláb, Z., Horváth, Z. (eds) Central European Functional Programming School. CEFP 2015. Lecture Notes in Computer Science(), vol 10094. Springer, Cham. https://doi.org/10.1007/978-3-030-28346-9_8
Download citation
DOI: https://doi.org/10.1007/978-3-030-28346-9_8
Published:
Publisher Name: Springer, Cham
Print ISBN: 978-3-030-28345-2
Online ISBN: 978-3-030-28346-9
eBook Packages: Computer ScienceComputer Science (R0)