[Haskell-cafe] ANN: Elerea, another FRP library
patai_gergely at fastmail.fm
Fri Apr 10 14:21:13 EDT 2009
> I've seen alot of FRP libraries come up, and I'm always left with the
> question, "Where the heck are the FRP tutorials?"
Writing a good tutorial takes a lot of time, but I made some example
code precisely to show how the library can be used. The best way to
learn is to start playing with them. The "chase" example is about as
small as it gets, and the breakout one is generally a nice test case for
such a library, as it exercises the code as well as provides a
reasonably complex example for the user to study.
The basic idea is indeed what Achim said: we refer to the whole lifetime
of some time-varying quantity (what I call a signal, but the name
behaviour is also often used for this concept in other systems) with a
single name. For instance, mousePosition is a two-dimensional vector
whose value follows the position of the mouse at any time. The
applicative interface means that you can combine signals using ordinary
point-wise functions by simple lifting. To keep with the example,
something like drawUnitRectangle <$> mousePosition would result in a
signal whose points are IO actions that draw the rectangle where the
mouse is at the moment you sample them. The drawUnitRectangle function
doesn't need to have anything reactive in it, it just takes an ordinary
pair (or whatever you represent your vectors with) and does its job.
In the end, a program working with signals looks very much like one
calculating a snapshot of the system and the state changes at the given
moment, except you need to insert <*>'s and lift values where
http://www.fastmail.fm - mmm... Fastmail...
More information about the Haskell-Cafe