extract main_loop into main_handle
extract main_loop into main_handle

Summary:
playing code golf. i think this is easier to read, because it separates `get_next_event` error handling from `main_handle_unsafe`'s error handling, and because `main_handle`'s signature is just `state -> event -> state`.

avoids an extra intermediate `result` by calling `main_handle_error` in 2 places instead of 1 (once if `get_next_event` fails, another if `main_handle_unsafe` fails).

Reviewed By: gabelevi

Differential Revision: D17721292

fbshipit-source-id: 57729243e83b63bed5af3e761d42b0a5de9011c2

facebook/flow,gabelevi/flow,samwgoldman/flow,gabelevi/flow,samwgoldman/flow,samwgoldman/flow,gabelevi/flow,facebook/flow,gabelevi/flow,mroch/flow,gabelevi/flow,mroch/flow,samwgoldman/flow,mroch/flow,gabelevi/flow,mroch/flow,mroch/flow,facebook/flow,facebook/flow,samwgoldman/flow,mroch/flow,mroch/flow,samwgoldman/flow,samwgoldman/flow,facebook/flow,facebook/flow,facebook/flow,gabelevi/flow