title: Haskell - readFile catch exception
body: <p>I am trying to read file in Haskell with exception catching but cant get working.
  The code looks like:</p>
  
  <pre><code>     module Main where
      import System.Environment
      import System.IO
      import System.Exit
  
      main = do
          x:xs &lt;- getArgs
          case length(x:xs) of
              2 -&gt; do catch (readFile x)
                          (\_ -&gt; do   putStrLn ("Error on reading file: " ++ x) 
                                      getLine
                                      exitWith ExitSuccess)
              _ -&gt; do putStrLn ("Run this way: ./projekt inputFile RE") &gt;&gt;
                  exitFailure
  </code></pre>
  
  <p>And I get this error:</p>
  
  <pre><code>Couldn't match expected type `IO String
                                -&gt; (ExitCode -&gt; IO a)
                                -&gt; ExitCode
                                -&gt; IO String'
         against inferred type `IO ()'
  In the expression:
      putStrLn
        ("Error on reading file: " ++ x) getLine exitWith ExitSuccess
  In the expression:
      do { putStrLn
             ("Error on reading file: " ++ x) getLine exitWith ExitSuccess }
  In the second argument of `catch', namely
      `(\ _ -&gt; do { putStrLn
                      ("Error on reading file: " ++ x) getLine exitWith ExitSuccess })'
  </code></pre>
  
  <p>Can you give me a hint?
  Thanks</p>