readEvent :: Wire s e IO a SDL.Event
(SDL.Event can be SDL.NoEvent or an event just like Netwire's events, so I guess they can be easily converted)
inputLogic :: Wire s m SDL.Event Position
(it keeps the position as an internal state and updates it according to the event)
render :: Wire s e IO Position ( )
(just writes the pixel to the screen)
And finally the game can be expressed using Arrow notation as:
readEvent>>>inputLogic>>>render
It works. But the thing here is that events like mouse movement are generated way faster than frames. To solve this, inputLogic should read all the input events until there are none and only then render the frame. I'm unable to do this using Wires. I've tried to make some kind of loop with ArrowLoop but I failed. I did came up with this solution, creating different wires:
readEvents :: Wire s e IO a [SDL.Event]
(it populates the list until there are no more events)
inputLogic' :: Wire s m [SDL.Event] Position
And the game is:
readEvents>>>inputLogic'>>>render
Which does the expected behaviour but it doesn't seem a good approach to me. These new wires aren't as basic as the first ones. Is this the best way to do it? Does anybody has a better idea?
Any advice will be considerably appreciated.