Journal of Information Processing Article

Posted on October 15, 2021

A Functional Reactive Programming Language for Small-Scale Embedded Systems with Recursive Data Types

Akihiko Yokoyama, Sosuke Moriguchi, Takuo Watanabe
Journal of Information Processing, Vol. 29, pp. 685-706, IPSJ, Oct., 2021. DOI:10.2197/ipsjjip.29.685


We introduce a new type system to Emfrp, a functional reactive programming (FRP) language designed for resource-constrained embedded systems. Functional reactive programming is a programming paradigm that allows concise descriptions of reactive systems such as GUIs by combining time-varying values that express values changing over time. Emfrp is a domain-specific language based on FRP, designed and developed for small-scale embedded systems. Because the language can statically determine the amount of runtime memory and guarantee the termination of reactive actions, a program written in Emfrp can safely continue reactive behaviors in resource-constrained environments. To ensure these properties, Emfrp disallows the use of recursive data types and functions. However, such restrictions often impose unnatural representations of data structures like lists or trees. The declarative characteristic of FRP and these restrictions impel us to write poorly maintainable redundant codes or deter us from writing certain types of programs. In this paper, we propose EmfrpBCT, an extended Emfrp with size-annotated recursive data types, to overcome this problem. The proposed system is more expressive than Emfrp, yet, it retains the aforementioned static properties. After explaining that through examples, we describe the features of EmfrpBCT, formalize the language, present an algorithm for statically computing the runtime memory bounds, and prove its soundness. Moreover, we implemented a compiler from EmfrpBCT to C, measured the translation time, and evaluated runtime overhead.