
28 Jan
2009
28 Jan
'09
4:50 p.m.
On Wed, Jan 28, 2009 at 4:00 PM, John Goerzen
* Catch doesn't work in many common cases anymore. In particular, the example right there in haddock is broken:
catch (openFile f ReadMode) (\e -> hPutStr stderr ("Couldn't open "++f++": " ++ show e))
That's broken, of course, because the type of e isn't fixed. But it's also broken because openFile has a different return type than hPutStr.
I think the correct code would be something like this:
catch (openFile f ReadMode)
(\(e::SomeException) ->
hPutStr stderr ("Couldn't open "++f++": " ++ show e)) >>
throwIO e)
Although it might be better to replace "SomeException" with "IOException".
--
Dave Menendez