Open ori-sky opened 8 years ago
If we separate out the startup/loop/shutdown code, we could run some kind of bracket to ensure that the shutdown code is run regardless of the loop succeeding or failing. The bracket would not be a typical IO bracket but would preferably be in some kind of 'exitable' monad which would allow the main loop to exit immediately without waiting until the end of a tick.
To clarify, an exitable monad would mean something like Except.
Currently on
logFatal
, the error message is logged as FATAL and an IO error is invoked to break out of the engine. However, this is undesirable as it doesn't allow the engine to gracefully exit.The Core monad should be additionally transformed over
ExceptT
to allow an error to be propagated to the point of engine creation.Currently this would still result in the engine shutdown methods not being invoked as the running of the engine would have already halted at this point. I'm unclear on a solution for this but it's paramount that one is devised as graceful shutdown is required.