I'm writing a function publish
, which needs to do some IO
, and also call a function in MonadBaseControl IO m
.The following works, but I would like to get rid of the constraint for MonadIO
, since it should be redundant with MonadBaseControl
publish :: (MonadIO m, MonadBaseControl IO m) => m ()
publish =
withResource $ \r ->
liftIO $ someIOAction r
withResource
is defined in Data.Pool, and has a MonadBaseControl IO m
constraint.
someIOAction
has the type r -> IO ()
I've read this question, but I can't figure out how to get rid of the second constraint: Is there any difference between "MonadIO m" and "MonadBaseControl IO m"?
If I remove MonadIO m
then I don't have liftIO
anymore. How do I execute an IO action from MonadBaseControl?