[Haskell-cafe] ANN: Elerea 1.2.3 with some enhancements

Patai Gergely patai_gergely at fastmail.fm
Sun Jan 31 05:03:11 EST 2010


Hello all,

I added a few new features to the experimental branch of Elerea [1], my
little FRP library. The previous release added random sources -- both
noise signals and instantaneous values within generators -- using
mersenne-random, and the current update added an extra primitive to
handle external events that can occur several times between samplings,
as I heard some people needed this. All the three variants of the
experimental interface support these additions.

Here's a simple example showing how the new externalMulti construct can
be used:

import Control.Monad
import FRP.Elerea.Experimental.Simple

main = do
  (gen,sink) <- externalMulti
  sig <- start $ do
    vals <- gen
    cnt <- stateful 10 (+1)
    return (liftM2 (:) cnt vals)
  let act = print =<< sig
  act
  sink 3
  act >> act
  sink 8 >> sink 2
  act
  sink 1 >> sink 7 >> sink 9
  act >> act >> act
  sink 4
  act

The program prints the following:

[10]
[11,3]
[12]
[13,2,8]
[14,9,7,1]
[15]
[16]
[17,4]

As you can see, all the input received since the last sampling is
collected in a list in reverse order. It is up to the programmer to
store these values somewhere or build further IO actions out of them.

Gergely

[1] http://hackage.haskell.org/package/elerea

-- 
http://www.fastmail.fm - Does exactly what it says on the tin



More information about the Haskell-Cafe mailing list