
Il giorno 08/ott/2014, alle ore 00:44, Nikita Volkov
Hi Nicola,
Hi!
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 Thank you, this solves my problem. I understand that exceptions are a different mechanism from ExceptT and similar, but I’m still trying to understand how exceptions are supposed to be integrated with the other error handling mechanisms (or vice versa).
Any pointers to better understand what components are involved and best practices for addressing this problems?
Best regards, Nikita Volkov
Thank you, Nicola