Skip to main content

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

  • Chapter
  • First Online:
Central European Functional Programming School (CEFP 2015)

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

Included in the following conference series:

  • 299 Accesses

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.

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

Access this chapter

Chapter
USD 29.95
Price excludes VAT (USA)
  • Available as PDF
  • Read on any device
  • Instant download
  • Own it forever
eBook
USD 59.99
Price excludes VAT (USA)
  • Available as EPUB and PDF
  • Read on any device
  • Instant download
  • Own it forever
Softcover Book
USD 74.99
Price excludes VAT (USA)
  • Compact, lightweight edition
  • Dispatched in 3 to 5 business days
  • Free shipping worldwide - see info

Tax calculation will be finalised at checkout

Purchases are for personal use only

Institutional subscriptions

References

  1. Ada, L.: adafruit/DHT-sensor-library (2017). https://github.com/adafruit/DHT-sensor-library

  2. Arduino.cc: (2015). https://www.arduino.cc

  3. Arduino.cc: Arduino LiquidCrystal Library (2015). https://www.arduino.cc/en/Reference/LiquidCrystal

  4. Arduino.cc: Arduino NewPing Library (2015). http://playground.arduino.cc/Code/NewPing

  5. Arduino.cc: Arduino Servo Library (2015). https://www.arduino.cc/en/Reference/Servo

  6. Arduino.org (2015). http://www.arduino.org/

  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/S0956796809007205

    Article  MathSciNet  MATH  Google Scholar 

  8. D-Robotics: DHT11 humidity & temperature sensor (2010). http://www.micro4you.com/files/sensor/DHT11.pdf

  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.1713263

    Article  Google Scholar 

  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. 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. Erkok, L.: hArduino (2014). https://hackage.haskell.org/package/hArduino

  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. Fowler, M.: Domain Specific Languages, 1st edn. Addison-Wesley Professional, Boston (2010)

    Google Scholar 

  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_1

    Chapter  Google Scholar 

  16. Hoefs, J.: Firmata protocol (2014). http://firmata.org/wiki/Main_Page

  17. Hudak, P.: Building domain-specific embedded languages. ACM Comput. Surv. 28(4es) (1996). https://doi.org/10.1145/242224.242477

    Article  Google Scholar 

  18. Ierusalimschy, R., de Figueiredo, L.H., Filho, W.C.: Lua - an extensible extension language. Softw. Pract. Exper. 26(6), 635–652 (1996)

    Article  Google Scholar 

  19. Ierusalimschy, R., de Figueiredo, L.H., Celes, W.: Lua 5.1 Reference Manual (2006). Lua.org

  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_12

    Chapter  Google Scholar 

  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_8

    Chapter  Google Scholar 

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

    Article  Google Scholar 

  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. Jones, N.D., Gomard, C.K., Sestoft, P.: Partial Evaluation and Automatic Program Generation. Prentice-Hall, Inc., Upper Saddle River (1993)

    MATH  Google Scholar 

  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. 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

    Chapter  Google Scholar 

  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. Lindberg, R.: frp-arduino (2015). https://github.com/frp-arduino/frp-arduino#contributing

  29. Nielson, H.R., Nielson, F.: Semantics with Applications: A Formal Introduction. Wiley, New York (1992)

    MATH  Google Scholar 

  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)

    MATH  Google Scholar 

  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. 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. Plasmeijer, R., van Eekelen, M., van Groningen, J.: Clean language report (version 2.2) (2011). http://clean.cs.ru.nl/Documentation

  34. Raspberrypi.org: Pi zero description (2015). https://www.raspberrypi.org/products/pi-zero/

  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. Suchocki, R., Kalvala, S.: MicroScheme: functional programming for the Arduino. In: Scheme Workshop (2014)

    Google Scholar 

  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. visualmicro.com: Debugging tutorial (2015). http://www.visualmicro.com/page/User-Guide.aspx?doc=Debugging-Walkthrough-Start.html

  39. Wadler, P.: The expression problem (1998). http://www.daimi.au.dk/~madst/tool/papers/expression.txt

  40. Williams, G.: The espruino project (2015). http://www.espruino.com/

Download references

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

Authors

Corresponding author

Correspondence to Pieter Koopman .

Editor information

Editors and Affiliations

A The Function

A The Function

For completeness, this appendix contains the complete function discussed in Sect. 5.

figure vc
figure vd
figure ve

Rights and permissions

Reprints and permissions

Copyright information

© 2019 Springer Nature Switzerland AG

About this chapter

Check for updates. Verify currency and authenticity via CrossMark

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)

Publish with us

Policies and ethics