Functional reactive programming (FRP) is a declarative programming paradigm for implementing reactive programs at a high level of abstraction. It applies functional programming principles to construct and manipulate time-varying values, also known as signals. However, for this programming paradigm to work in practice, an FRP language must ensure that programs are causal, productive, and free of space leaks. Over the past fifteen years, several modal type systems to enforce these operational properties have been developed. We present a new FRP language with a significantly simplified modal type system that imposes fewer restrictions than previous modal FRP languages while still guaranteeing the central operational properties of causality, productivity, and absence of space leaks. The key enabling idea is to alter the semantics of signals so that the type system can safely allow more programs to type-check, thereby making the language more expressive, too. With this new semantics, signals are modelled as mutable references whose mutability is tightly controlled by the 'later' type modality. This disciplined form of mutability also enables more efficient in-place updates of signals, all while preserving a functional programming style.
翻译:函数式响应式编程(FRP)是一种声明式编程范式,用于在高层抽象级别实现响应式程序。它应用函数式编程原则来构建和操作随时间变化的值(也称为信号)。然而,为了使该编程范式在实践中可行,FRP语言必须确保程序具有因果性、生产性且无空间泄漏。过去十五年间,已开发出多种用于强制执行这些操作属性的模态类型系统。我们提出了一种新的FRP语言,其模态类型系统显著简化,比先前的模态FRP语言施加更少的限制,同时仍能保证因果性、生产性及无空间泄漏等核心操作属性。其关键实现思路是改变信号的语义,使得类型系统能够安全地允许更多程序通过类型检查,从而也增强了语言的表达能力。在这种新语义下,信号被建模为可变引用,其可变性受到“later”类型模态的严格约束。这种受控的可变形式还支持对信号进行更高效的原位更新,同时保持了函数式编程风格。