Hi Nicola,
Exceptions are a completely unrelated mechanism to all the monad transformers. Roughly speaking, it’s a dirty low level hack into Haskell’s type system. The error-transformer solutions on the other hand are just libraries, which utilize Haskell’s standard features. So there is no relation between the two, other then that they approach the same set of problems.
Concerning your specific problem, the
try
function is there to help you. In your final solution you may utilize a function in the spirit of the following:data ParserError = IOError IOException | LexingError <fields> | ParsingError <fields> safeLiftIO :: IO a -> Parser a safeLiftIO io = liftIO (try io) >>= either (throwError . IOError) return
Best regards,
Nikita Volkov