[Haskell-cafe] Improving event management in elerea
jean legrand
kkwweett at yahoo.fr
Thu Aug 13 23:07:20 EDT 2009
> detected on a bool signal. In that case, it would be easier
> to define it
> in terms of transfer:
>
> accumIf :: a -> (a -> a) -> Signal Bool ->
> SignalMonad (Signal a)
> accumIf v0 f b = transfer v0 g b
> where g _dt c x0 = if c then f x0 else x0
>
> event :: a -> Signal Bool -> (a -> a) ->
> SignalMonad (Signal a)
> event v0 b f = accumIf v0 f =<< edge b
nice
> Also, your flat function is practically equivalent to
> (return . pure),
> why did you define it using transfer?
lack of reflex (and reflexion !)
> Another thing to note is that you might want to define
> playerX as an
> integral of a velocity derived from lpress and rpress, so
> you wouldn't
> need to press and release the buttons repeatedly, and the
> speed would be
> the same regardless of sampling rate, since integral takes
> the time step
> into account.
>
or
event :: a -> Signal Bool -> (a -> a) -> SignalMonad (Signal a)
event v0 b f = accumIf v0 f =<< return b
?
> For instance, the accumIf function is a conditional version
> of stateful,
> and it might be generally useful. Whether it's the best
> name, that's
> another question.
>
> Gergely
thank you for your very helpful post
More information about the Haskell-Cafe
mailing list