Added state to the hook functions.

The initial state is created in module AppDelegate.
It is passed to Objective-C which simply passes it back
as the first argument to all of the hook functions. This
way we do not have to use unsafePerformIO to create
a global state which the hook functions manipulate.
I'm not 100% sure the extra syntactic burden is worth
the purity, but it's what I've gone with.