Remove spurious IO requirement.

It seems the code was written using an IORef which caused MonadIO to be required when simply Monad would have done. I modified it to be based on StateT and ran the included tests.

My motivation for this is I have to run it where I can't access IO.