
However, the definition of bracket relies on block and unblock, which have the following types:
bracket :: IO a -> (a -> IO b) -> (a -> IO c) -> IO c block :: IO a -> IO a unblock :: IO a -> IO a
This forces f to be an IO action in the above withQuery function. If bracket, block, and unblock had these types, my helper function would be well typed:
bracket :: MonadIO m => m a -> (a -> m b) -> (a -> m c) -> m c block :: MonadIO m => m a -> m a unblock :: MonadIO m => m a -> m a
Would anything prevent block, unblock, bracket (and other similar functions working on IO actions) from being generalized to all intances of MonadIO?
I'm afraid I can't see a way to generalise the types of block and unblock, since they are based on underlying primitives that really do have type (IO a -> IO a). Perhaps if your monad is isomorphic to IO, it could be done, but otherwise I don't think it's possible. Unless I'm missing something. Cheers, Simon