This article presents Rhine, an FRP library written in Haskell. The implementation at https://github.com/turion/rhine is usable. The article has been submitted to Haskell Symposium 2018.
Processing data at different rates is generally a hard problem in reactive programming.
Buffering problems, lags, and concurrency issues readily occur.
Many of these problems are clock errors,
where data at different rates is combined incorrectly.
Techniques to avoid clock errors,
such as type level clocks and deterministic scheduling,
exist in the field of synchronous programming,
but are not implemented in general-purpose languages like Haskell.
Rhine is a clock-safe library for synchronous and asynchronous Functional Reactive Programming (FRP).
It separates the aspects of clocking, scheduling and resampling from each other,
and ensures clock-safety on the type level.
It offers a general-purpose framework that can be used for game development, media applications, GUIs and embedded systems,
through a flexible API with many reusable components.
Side effects can be reasoned about at the type level,
allowing, e.g., for deterministic scheduling and resampling.
Through the generality of clocks in Rhine,
classical FRP concepts like events and behaviours can be unified.
Concurrent communication is encapsulated safely.
Diverse reactive subsystems can be combined in a coherent, declarative data flow framework,
while the interoperability of the different data rates is guaranteed by type level clocks.