title: Can't catch "Prelude.read: no parse" exception with Control.Exception.try
body: <p>I trying to read some value out of a file and catch every exception that might occur (in the mindset of <a href="http://docs.python.org/3/glossary.html#term-eafp" rel="noreferrer">"Easier to ask for forgiveness than permission"</a>). I am having trouble catching the <code>Prelude.read: no parse</code> exception though. To tell <code>try</code> that it should catch every exception I define <code>tryAny</code> with the explicit type <code>SomeException</code> which to my knowledge is the "super type" of every exception:</p>
  
  <pre><code>import Control.Exception (try,SomeException)
  tryAny :: IO a -&gt; IO (Either SomeException a)
  tryAny = try
  </code></pre>
  
  <p>With <code>tryAny</code> I seem to be able to catch IO errors:</p>
  
  <pre><code>&gt; tryAny (fromFile "nonExistingFileName")
  Left nonExistingFileName: openFile: does not exist (No such file or directory)
  </code></pre>
  
  <p>But the read error will not be caught:</p>
  
  <pre><code>&gt; tryAny (return ((read "a")::Int))
  Right *** Exception: Prelude.read: no parse
  </code></pre>
  
  <p>What can I do to catch every exception?</p>