I created an equivalent function a while ago when I needed to wait for a signal that the PR2 arm had reached its destination before sending the next arm position goal (see waitFor). I think this is a general and basic enough function that it is worth including in Topic.Util.
The test might rely upon implementation details of Topic timing.
I believe bothNew can be written in terms of firstThenSecond as:
bothNew' :: Topic IO a -> Topic IO b -> Topic IO (a, b)
bothNew' x y = Topic $ do
(x1, x2) <- tee x
(y1, y2) <- tee y
runTopic $ merge (firstThenSecond x1 y1) (swap <$> firstThenSecond y2 x2)
I created an equivalent function a while ago when I needed to wait for a signal that the PR2 arm had reached its destination before sending the next arm position goal (see waitFor). I think this is a general and basic enough function that it is worth including in Topic.Util.
The test might rely upon implementation details of Topic timing.
I believe bothNew can be written in terms of firstThenSecond as: