I have a function that returns type ErrorT String IO (). While the function works, liftIO‘s litter every line that does IO. It makes for a mess. Is there any way to get around this and still have the ability to abort on error?
I have a function that returns type ErrorT String IO () . While the
Share
I assume this is the context of the question, so I’ll repost the comment I left over there in case you didn’t notice it:
If you use a few particular functions a lot, you could write a wrapper around them, e.g.
liftedPutStr = liftIO . putStr. You could even import the originals qualified and make your lifted version use the same name, if you wanted. Also, a group of IO actions that won’t raise errors can be pulled out into a single, separate function that can then beliftIOd just once. Does that help?In case you’re not familiar with qualified imports, here’s
putStragain as an example:That should let you use the altered
putStrin a transformedIOthe same way you’d normally use the realputStrin plainIO.