Because the types have changed. In particular:
- OldException:
catch :: IO a -> (Exception -> IO a) -> IO a - Exception:
catch :: Exception e => IO a -> (e -> IO a) -> IO a
The new model should know that the value of e for type Exception e . In fact, this means that you need to tell the compiler which exception you are catching. Your OldException example catches everything that is now discouraging (see "Catching All Exceptions" for more information).
A simple fix for your function would look something like this:
foo = (readFile "foo") `E.catch` (\e -> const (return "") (e :: E.IOException))
Or without lambda version:
bar = (readFile "foo") `E.catch` myHandler myHandler :: E.IOException -> IO String myHandler _ = return ""
source share