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.
IntroductionThe internet of things, IoT, will for a large part consist of devices equipped with a small microprocessor executing some tailor made program. The Arduino is a family of popular open-source microcontroller boards [2,3]. The Arduino Uno is the archetype of these development boards. The first version was released in 2005. The current version, R3, of this board contains a 8-bit ATMega328 microprocessor running at 16 MHz. It provides 32 KB of flash memory and 2 KB RAM. This board is very suited for control tasks since it provides 14 digital input/output pins (of which 6 can be used as PWM outputs), 6 analog inputs, and serial communication via an USB connection. Arduino boards can be extended by shields. These shields provide various kinds of additional input/output options like motor controls, Blue Tooth communication, Ethernet, LCD, buttons and relays. These elementary and cheap systems are extremely well suited for simple input/output intensive control tasks.From a software point of view these tiny systems are too small to run any operating system. The standard way to program Arduino's uses it's own dialect of C++. The Arduino IDE compiles this to binary code. This code is uploaded to the Arduino via an USB connection. For this purpose every Arduino is shipped with a tiny boot loader. Arduino programs define two functions for creating a runnable program. The setup() function is executed once to initialize the board,