-- Build the FRP network
buildNetwork :: IORef Resources -> CoreEventGenerators -> IO ()
buildNetwork resRef evGens = do
  B.actuate <=< B.compile $ mdo
    coreEvents <- mkCoreEvents evGens

    -- currentTime isn't currently used, but it's useful for things like animation
    currentTime <- B.accumB 0 ((+) <$> eTime coreEvents)

    let evs = unionFirst [ Tick        <$> eTime coreEvents -- step the physics
                         , procKeyDown <$> keyDown coreEvents
                         , procKeyUp   <$> keyUp coreEvents
                         ]

    -- Step the game model forward every time we get a new event
    mdl <- B.accumB newGame (gameStep <$> evs)

    -- every time we get a 'render' event tick, draw the screen
    B.reactimate $ readerFromIORef resRef <$>
      (renderGame <$> scrSizeB coreEvents <*> mdl <*> currentTime)
      <@ eRender coreEvents
buildNetwork :: IORef Resources -> CoreEventGenerators -> IO ()
buildNetwork resRef evGens = do
  B.actuate <=< B.compile $ mdo
    coreEvents <- mkCoreEvents evGens

    -- currentTime isn't currently used, but it's useful for things like animation
    currentTime <- B.accumB 0 ((+) <$> eTime coreEvents)

    let evs = unionFirst [ Tick        <$> eTime coreEvents -- step the physics
                         , procKeyDown <$> keyDown coreEvents
                         , procKeyUp   <$> keyUp coreEvents
                         ]

    -- Step the game model forward every time we get a new event
    mdl <- B.accumB newGame (gameStep <$> evs)

    -- every time we get a 'render' event tick, draw the screen
    B.reactimate $ readerFromIORef resRef <$>
      (renderGame <$> scrSizeB coreEvents <*> mdl <*> currentTime)
      <@ eRender coreEvents
buildNetwork resRef evGens = do
  B.actuate <=< B.compile $ mdo
    coreEvents <- mkCoreEvents evGens

    -- currentTime isn't currently used, but it's useful for things like animation
    currentTime <- B.accumB 0 ((+) <$> eTime coreEvents)

    let evs = unionFirst [ Tick        <$> eTime coreEvents -- step the physics
                         , procKeyDown <$> keyDown coreEvents
                         , procKeyUp   <$> keyUp coreEvents
                         ]

    -- Step the game model forward every time we get a new event
    mdl <- B.accumB newGame (gameStep <$> evs)

    -- every time we get a 'render' event tick, draw the screen
    B.reactimate $ readerFromIORef resRef <$>
      (renderGame <$> scrSizeB coreEvents <*> mdl <*> currentTime)
      <@ eRender coreEvents