[Haskell-cafe] Animas/Yampa - Using Zip as a Routing Function in a Parallel Switch with Feedback

Ertugrul Soeylemez es at ertes.de
Tue Sep 20 11:45:50 CEST 2011

"M. George Hansen" <technopolitica at gmail.com> wrote:

> I've been playing around with functional reactive programming using
> Animas/Yampa and ran into a strange situation. I'm using a parallel
> switch to route input to a collection of signal functions and using
> the output as feedback (to simulate state). Everything works as
> expected until I attempt to use zip as a routing function (i.e. pair
> each element of input with a signal function). Using zip as a routing
> function causes the program to enter an infinite loop when it
> evaluates the output from the parallel switch.

I'm not totally sure, but I sense that you may need a one-instant delay
in your looping code here:

>         rec
>             let senses = map (\state -> (inputEvents, state)) states
>             states <- par route activities -< senses

Try adding a one-instant delay by passing the output of your parallel
switch through the iPre signal function:

    states <- iPre [] <<< par route activities -< senses

Hope that helps.


nightmare = unsafePerformIO (getWrongWife >>= sex)

More information about the Haskell-Cafe mailing list