haskell-game/sdl2 — pull request #19 by afwlehmann (2014-10-23 12:16:40+00:00)
Title: Timer support

Hi,

I've added `delay`, `addTimer` and `removeTimer`.

Regarding `addTimer` I'm not sure whether using `Word32` all over the place is the best way. The semantics of the timer creation are as follows:
- Creating a timer with initial delay `0` creates a timer and (almost) immediately fires it.
- Creating a timer with initial delay greater than `0` works as expected.
- Returning `0` from a timer cancels it.
- Returning something greater than `0` causes the timer to be rescheduled at the newly returned interval.

What do you think about wrapping either (or both) the initial and returned delays into an algebraic data type? Would that make sense? The semantics for both delays are slightly different in that an initial `0` means "Immediate" whether a returned `0` means "Cancelled". We could use a GADT but having constructors like "Immediate | Cancelled | FireAfter" where the subtle difference between the first two is not immediately clear seems a bit awkward. What do you think?