I assume this is the context of the question , so I will post a comment that I left there if you did not notice it:
If you use several specific functions, you can write a wrapper around them, for example. liftedPutStr = liftIO . putStr liftedPutStr = liftIO . putStr . You can even import originals and make your canceled version the same name if you want. In addition, a group of I / O operations that will not cause errors can be output to one separate function, which can be liftIO d only once. Does it help?
If you are not familiar with qualified imports, here putStr again as an example:
import Prelude hiding (putStr) import qualified Prelude as P import Control.Monad.Trans putStr x = liftIO $ P.putStr x
This will allow you to use the modified putStr in the converted IO just as you would normally use the real putStr in a simple IO .
source share