
or
event :: a -> Signal Bool -> (a -> a) -> SignalMonad (Signal a) event v0 b f = accumIf v0 f =<< return b
? That's not a good idea, because it doesn't take time into consideration, so you'd jump a huge amount in every frame. What I had in mind is something like this:
ifte :: Signal Bool -> Signal a -> Signal a -> Signal a ifte sc st sf = (\c t f -> if c then t else f) <$> sc <*> st <*> sf And then: playerX <- integral playerX0 ( ifte (lpress &&@ (playerX >@ pure (-fieldW))) (-1) 0 + ifte (rpress &&@ (playerX <@ pure (fieldW-playerW))) (1) 0 ) This won't be perfect, since the paddle can get a bit beyond the edge of the field. This can be prevented by using some kind of clamped integral, for instance, which you can again define in terms of transfer, just like the plain integral. Also, note that mixing bind and return is redundant, since "f =<< return b" is equivalent to "f b". Gergely -- http://www.fastmail.fm - Choose from over 50 domains or use your own