Functional Reactive Programming in Scala
Solution 1
See also Odersky et al.'s paper "Deprecating the Observer Pattern". It explains the library Scala.React, which was developed for the paper.
Solution 2
There's reactive -- http://github.com/nafg/reactive. The repository currently contains two projects. reactive-core is a standalone FRP library. reactive-web builds on it to make it very easy to make very dynamic and interactive Lift webapps.
Solution 3
There is scala-reactive: http://github.com/erikrozendaal/scala-reactive
It is inspired by Microsoft's Reactive Extensions library, with an Observable trait taking the place of IObservable, and tailored to the Scala collections API as much Rx is to the LINQ API.
Daniel C. Sobral
I have been programming for more than 20 years now, starting with 8 bits computers, assembler and BASIC. My passion for languages meant that, by the time I entered college, I had already programmed for fun or profit in more than 20 languages, including odd ones like Forth, MUMPS and APL, as well as theoretically important ones like Lisp and Prolog. Some of my code ended up in FreeBSD, of which I was a committer for some years, while I got my masters degree in the field of distributed algorithms. I also contributed to Scala, with small amounts of code, some reasonable amount of documentation, and a couple of years of a lot of attention to the Scala questions on Stack Overflow.
Updated on April 29, 2020Comments
-
Daniel C. Sobral almost 4 years
Are there any libraries written for Scala enabling Functional Reactive Programming?
-
Roland Tepp over 13 yearsThis paper is actually very good. It really made me understand what is all the fuzz in FRP all about...
-
Mariusz Pawelski over 11 yearshere is new version.
-
Jeff Axelrod over 11 yearsAlso see stackoverflow.com/q/11619680/403455
-
Shelby Moore III over 11 years@DanielC.Sobral I provided an example for inverting the control of state using Scala's delimited continuations, not just inversion-of-control of caller/callee, which afaics that paper and Scala.React don't do.
-
Owen about 11 yearsI tried reactive-core in a Swing GUI and found it quite pleasant to use. The biggest pain is actually language related -- Scala could use nicer syntax for applicatives.
-
nafg about 11 years@Owen - that's interesting. Where do you use applicatives? P.S. Do you have a Swing bridge that's shareable?
-
Owen about 11 years
Signal
is an applicative. And I didn't use any sort of bridge; I just mixed reactive code in with Swing code -- a little messy since the swing components are so stateful, but usable. The whole thing will be on github eventually. -
nafg about 11 yearsHow is Signal an applicative?
-
Owen about 11 years
pure
is a constant signal, andap
is doing azip
followed by amap
. So if say I have a signalx
and a signaly
and I want a signalx + y
,x zip y map { case (x, y) => x+y }
is like scalaz(x |@| y)(_ + _)
. -
nafg about 11 yearsAh thanks for the info. If you like, feel free to open an issue to add applicative syntax.
-
Vadzim over 10 years
-
nafg almost 10 years@Owen just added it. github.com/nafg/reactive/commit/…