You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm having issues using pSwitchB. I've made a simple program below that demonstrates the issue. When the switch occurs (input value is 3), this goes into an infinite loop, presumably because each time the switch occurs, a new one is immediately triggered. I though using dpSwitchB would solve this problem, but it only delays the issue till the next sample. Am I using (d)pSwitchB incorrectly?
module Main where
import FRP.Yampa
eventAt3 :: SF Integer (Event ())
eventAt3 = arr $ \t -> if t == 3
then Event ()
else NoEvent
swit :: [SF Integer (Event ())] -> SF Integer [Event ()]
swit actors = pSwitchB
actors
(arr (\(_, es) -> () <$ catEvents es))
(\colSfs _ -> swit colSfs)
main :: IO ()
main = print $ embed (swit [eventAt3]) (0, [(1,Just 1),(1,Just 1),(1,Just 2),(1,Just 3),(1,Just 4)])
The text was updated successfully, but these errors were encountered:
So that would solve the infinite loop, but it isn't the behaviour I am looking for: I need to keep the actor. What I ultimately want is for actors to be able to spawn new actors, so the code would actually look more like this:
The combined signal functions are recursively switching to each other because they both produce a trigger event at time 3. Using a delayed combinator is no help because
it does not change the input, and
the signal functions before and after the switch are the same, so their output is the same.
The solution is to pass the trigger event signal through notYet, which suppresses events at local time 0. Therefore the first signal function will switch at time 3 (local time 3) and the second signal function will not switch at time 3 (local time 0).
I'm having issues using pSwitchB. I've made a simple program below that demonstrates the issue. When the switch occurs (input value is 3), this goes into an infinite loop, presumably because each time the switch occurs, a new one is immediately triggered. I though using dpSwitchB would solve this problem, but it only delays the issue till the next sample. Am I using (d)pSwitchB incorrectly?
The text was updated successfully, but these errors were encountered: