Advertisement

Type-Safe Functions and Tasks in a Shallow Embedded DSL for Microprocessors

  • Pieter KoopmanEmail author
  • Rinus Plasmeijer
Chapter
Part of the Lecture Notes in Computer Science book series (LNCS, volume 10094)

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.

Keywords

Task oriented programming Embedded systems Internet of Things Domain specific language Shallow embedding User-defined functions 

Notes

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.

Supplementary material

References

  1. 1.
    Ada, L.: adafruit/DHT-sensor-library (2017). https://github.com/adafruit/DHT-sensor-library
  2. 2.
    Arduino.cc: (2015). https://www.arduino.cc
  3. 3.
    Arduino.cc: Arduino LiquidCrystal Library (2015). https://www.arduino.cc/en/Reference/LiquidCrystal
  4. 4.
    Arduino.cc: Arduino NewPing Library (2015). http://playground.arduino.cc/Code/NewPing
  5. 5.
    Arduino.cc: Arduino Servo Library (2015). https://www.arduino.cc/en/Reference/Servo
  6. 6.
    Arduino.org (2015). http://www.arduino.org/
  7. 7.
    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/S0956796809007205MathSciNetCrossRefzbMATHGoogle Scholar
  8. 8.
    D-Robotics: DHT11 humidity & temperature sensor (2010). http://www.micro4you.com/files/sensor/DHT11.pdf
  9. 9.
    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.1713263CrossRefGoogle Scholar
  10. 10.
    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
  11. 11.
    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
  12. 12.
  13. 13.
    Feeley, M., Miller, J.S., Rozas, G.J., Wilson, J.A.: Compiling higher-order languages into fully tail-recursive portable C. Technical report (1997)Google Scholar
  14. 14.
    Fowler, M.: Domain Specific Languages, 1st edn. Addison-Wesley Professional, Boston (2010)Google Scholar
  15. 15.
    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_1CrossRefGoogle Scholar
  16. 16.
    Hoefs, J.: Firmata protocol (2014). http://firmata.org/wiki/Main_Page
  17. 17.
    Hudak, P.: Building domain-specific embedded languages. ACM Comput. Surv. 28(4es) (1996).  https://doi.org/10.1145/242224.242477CrossRefGoogle Scholar
  18. 18.
    Ierusalimschy, R., de Figueiredo, L.H., Filho, W.C.: Lua - an extensible extension language. Softw. Pract. Exper. 26(6), 635–652 (1996)CrossRefGoogle Scholar
  19. 19.
    Ierusalimschy, R., de Figueiredo, L.H., Celes, W.: Lua 5.1 Reference Manual (2006). Lua.org
  20. 20.
    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_12CrossRefGoogle Scholar
  21. 21.
    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_8CrossRefGoogle Scholar
  22. 22.
    Johann, P., Ghani, N.: Foundations for structured programming with GADTs. SIGPLAN Not. 43(1), 297–308 (2008)CrossRefGoogle Scholar
  23. 23.
    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
  24. 24.
    Jones, N.D., Gomard, C.K., Sestoft, P.: Partial Evaluation and Automatic Program Generation. Prentice-Hall, Inc., Upper Saddle River (1993)zbMATHGoogle Scholar
  25. 25.
    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
  26. 26.
    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_6CrossRefGoogle Scholar
  27. 27.
    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
  28. 28.
  29. 29.
    Nielson, H.R., Nielson, F.: Semantics with Applications: A Formal Introduction. Wiley, New York (1992)zbMATHGoogle Scholar
  30. 30.
    Peyton Jones, S.L.: The Implementation of Functional Programming Languages. Prentice-Hall International Series in Computer Science. Prentice-Hall, Inc., Upper Saddle River (1987)zbMATHGoogle Scholar
  31. 31.
    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
  32. 32.
    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
  33. 33.
    Plasmeijer, R., van Eekelen, M., van Groningen, J.: Clean language report (version 2.2) (2011). http://clean.cs.ru.nl/Documentation
  34. 34.
    Raspberrypi.org: Pi zero description (2015). https://www.raspberrypi.org/products/pi-zero/
  35. 35.
    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
  36. 36.
    Suchocki, R., Kalvala, S.: MicroScheme: functional programming for the Arduino. In: Scheme Workshop (2014)Google Scholar
  37. 37.
    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
  38. 38.
  39. 39.
    Wadler, P.: The expression problem (1998). http://www.daimi.au.dk/~madst/tool/papers/expression.txt
  40. 40.
    Williams, G.: The espruino project (2015). http://www.espruino.com/

Copyright information

© Springer Nature Switzerland AG 2019

Authors and Affiliations

  1. 1.Institute for Computing and Information SciencesRadboud UniversityNijmegenThe Netherlands

Personalised recommendations