[Haskell-cafe] ANN: Netwire 1.2.0
Ertugrul Soeylemez
es at ertes.de
Tue Sep 6 13:50:56 CEST 2011
Hello there,
version 1.2.1 of netwire is out. New features include:
* Completely reworked event system. Events are now solely based on
signal inhibition, which turns out to be much more convenient and
faster than AFRP's traditional approach using Maybe-wrapped values.
Now instead of checking for the presence of an event, you simply
assume that it happened. If it didn't happen, then the signal is
inhibited and your wire is not run. This makes your code much
simpler, because you get along almost entirely without switches.
Example displaying a discrete clock updated at intervals of half a
second:
system :: forall m. Monad m => Wire m () String
system =
proc _ -> printf "%8.2f" ^<< hold discreteClock -< ()
where
discreteClock :: Wire m () Double
discreteClock =
proc _ -> do
t <- time -< ()
repeatedly -< (0.5, t)
By using ArrowPlus or Alternative, you can handle the case, where
the event did not happen, listening for alternative events or simply
having a fallback. By using the various wire combinators you can
hold, sample, keep or exhibit event values as shown above.
* Lots and lots of Haddock documentation improvements. Now the
inhibition and feedback behaviour of every builtin wire is
documented.
* Apropos feedback: Finally added an ArrowLoop instance, so you can
now have recursive values in your wires. There is a catch though:
Right now wires which produce values used recursively must not
inhibit. There is an inherent problem handling the inhibition case,
which you will observe as a pattern match error.
Right now I don't have a solution for this problem, but I'm working
on it. However, it may well be that it simply cannot be solved with
my current internal wire representation. This is the price to pay
for signal inhibition.
To prevent (or rather catch) inhibition you can use the 'exhibit' or
'event' combinators.
* Many small performance improvements. Simple signal networks go well
beyond 35000 frames per second on my mobile Intel i7 with 1.7 GHz
and their executables cost well less than 5 MiB RAM. The
performance passes the 50k FPS mark on my i5 with 2.8 GHz at home.
This is more than a 10x speedup compared to my last benchmark on the
initial release of version 1.0.0
* Removed some of variations of existing wires and replaced them by
wire combinators instead. For example 'executeOnce' and
'executeEvery' are gone. Instead you should use the normal
'execute' wire together with 'swallow', 'sample', 'hold' or other
combinators.
* Changed the semantics of all wires to support feedback. Now some
wires support feedback right away, while for others you need a
one-instant delay. The feedback behaviour of all wires is
Haddock-documented, as noted.
Enjoy and please give me as much feedback as possible. =)
Greets,
Ertugrul
--
nightmare = unsafePerformIO (getWrongWife >>= sex)
http://ertes.de/
More information about the Haskell-Cafe
mailing list