FailWhaleBrigade / water-wars

Game in Haskell
Other
14 stars 4 forks source link

Refactor eventloop #16

Closed fendor closed 6 years ago

fendor commented 6 years ago

Refactor the previously stateful event loop implementation into message reduction and side effect execution. We implement a DSL that is emitted by the message reduction. The implementation aims to imitate an event sourcing architecture inspired by elm. This makes testing easier, because the complex reaction of messages is now split into digestible commands. Furthermore, the commands are composable. The fine grained use of TVar's has been abandoned in favour of a single global TVar. All mutation to that single global has to be performed in the function runEventLoop. No other function is allowed to mutate this variable, but only to read