<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;"><br><div><div>Il giorno 08/ott/2014, alle ore 00:44, Nikita Volkov <<a href="mailto:nukasu.kanaka@gmail.com">nukasu.kanaka@gmail.com</a>> ha scritto:</div><br class="Apple-interchange-newline"><blockquote type="cite"><div dir="ltr"><div></div><div class="markdown-here-wrapper" style=""><p style="margin:1.2em 0px!important">Hi Nicola,</p></div></div></blockquote><div>Hi!</div><blockquote type="cite"><div dir="ltr"><div class="markdown-here-wrapper" style=""><p style="margin:1.2em 0px!important">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.</p><p style="margin:1.2em 0px!important">Concerning your specific problem, the <a href="http://hackage.haskell.org/package/base-4.7.0.1/docs/Control-Exception-Base.html#v:try"><code style="font-size:0.85em;font-family:Consolas,Inconsolata,Courier,monospace;margin:0px 0.15em;padding:0px 0.3em;white-space:pre-wrap;border:1px solid rgb(234,234,234);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px;display:inline;background-color:rgb(248,248,248)">try</code></a> function is there to help you. In your final solution you may utilize a function in the spirit of the following:</p>
<pre style="font-size:0.85em;font-family:Consolas,Inconsolata,Courier,monospace;font-size:1em;line-height:1.2em;margin:1.2em 0px"><code style="font-size:0.85em;font-family:Consolas,Inconsolata,Courier,monospace;margin:0px 0.15em;padding:0px 0.3em;white-space:pre-wrap;border:1px solid rgb(234,234,234);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px;display:inline;background-color:rgb(248,248,248);white-space:pre;overflow:auto;border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px;border:1px solid rgb(204,204,204);padding:0.5em 0.7em;display:block!important;display:block;padding:0.5em;color:rgb(51,51,51);background:rgb(248,248,255)">data ParserError = 
  IOError IOException | LexingError <fields> | ParsingError <fields>

safeLiftIO :: IO a -> Parser a
safeLiftIO io =
  liftIO (try io) >>= either (throwError . IOError) return
</code></pre></div></div></blockquote><div>Thank you, this solves my problem.</div><div>I understand that exceptions are a different mechanism from ExceptT</div><div>and similar, but I’m still trying to understand how exceptions are supposed</div><div>to be integrated with the other error handling mechanisms (or vice versa).</div><div><br></div><div>Any pointers to better understand what components are involved and</div><div>best practices for addressing this problems?</div><blockquote type="cite"><div dir="ltr"><div class="markdown-here-wrapper" style=""><p style="margin:1.2em 0px!important">Best regards,<br>Nikita Volkov</p>
<div title="MDH:PGRpdj5IaSBOaWNvbGEsPC9kaXY+PGRpdj48YnI+PC9kaXY+PGRpdj5FeGNlcHRpb25zIGFyZSBh
IGNvbXBsZXRlbHkgdW5yZWxhdGVkIG1lY2hhbmlzbSB0byBhbGwgdGhlIG1vbmFkIHRyYW5zZm9y
bWVycy4gUm91Z2hseSBzcGVha2luZywgaXQncyBhIGRpcnR5IGxvdyBsZXZlbCBoYWNrIGludG8g
SGFza2VsbCdzIHR5cGUgc3lzdGVtLiBUaGUgZXJyb3ItdHJhbnNmb3JtZXIgc29sdXRpb25zIG9u
IHRoZSBvdGhlciBoYW5kIGFyZSBqdXN0IGxpYnJhcmllcywgd2hpY2ggdXRpbGl6ZSBIYXNrZWxs
J3Mgc3RhbmRhcmQgZmVhdHVyZXMuIFNvIHRoZXJlIGlzIG5vIHJlbGF0aW9uIGJldHdlZW4gdGhl
IHR3bywgb3RoZXIgdGhlbiB0aGF0IHRoZXkgYXBwcm9hY2ggdGhlIHNhbWUgc2V0IG9mIHByb2Js
ZW1zLjwvZGl2PjxkaXY+PGJyPjwvZGl2PjxkaXY+Q29uY2VybmluZyB5b3VyIHNwZWNpZmljIHBy
b2JsZW0sIHRoZSBbYHRyeWBdKGh0dHA6Ly9oYWNrYWdlLmhhc2tlbGwub3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