A high-performance, purely-functional library for reactive programming based on efficient incremental computation.
This library aims at faithfully implementing Functional Reactive Programming as defined in [2]. The term Reactive programming is often used to describe composing streams of discrete events. Functional reactive programming (FRP) is about composing dynamic values changing in continuous time and reacting to discrete events.
Behaviour[A](value: Reactive[TimeFun[A]])
- value chaninging over time.
Event[ A](value: Future[Reactive[A]])
- stream of (Time, a) pairs.
Reactive[ A](head: A, tail: Event[A])
- reactive value.
Sink[A, B](f: A => IO[Void, Unit])
- consumer of reactive values.
This project is just starting, so the working example is quite simple:
case class Tick(name: String)
def ticks(interval: Duration, name: String): Event[Tick] =
Event(IO.point { (Time.now, Reactive(Tick(name), ticks(interval, name).delay(interval))) })
def myAppLogic: IO[Void, Unit] =
Sink[Tick, Unit](t => IO.now(println(s"tick ${t.name}")))
.sink(
ticks(0.2 second, "a")
.merge(ticks(0.4 second, "b"))
)
This program produces a scalaz.zio.IO
that can be run by e.g. scalaz.zio.App
- see TwoTickers.scala
in examples
.
- Functional Reactive Programming by Stephen Blackheath and Anthony Jones, Manning Publications
- Push-Pull Functional Reactive Programming paper by Conal Elliot
- Haskell Functional Reactive Programming
- Overview of Haskell FRP libraries
- frp-zoo: Several implementation of a simple program with different FRP libraries
- Controlling time and space: understanding the many formulations of FRP presentation based on ELM