On Mon, Nov 3, 2008 at 7:27 PM, shelarcy <[EMAIL PROTECTED]> wrote: > On Tue, 04 Nov 2008 07:40:50 +0900, David Menendez <[EMAIL PROTECTED]> wrote: >>> ie: >>> >>> action >>> `catches` >>> [ \(e :: ExitCode) -> ... >>> , \(e :: PatternMatchFail) -> ... >>> ] >>> >>> or just by using multiple catch clauses: >>> >>> action >>> `catch` (\(e :: ExitCode) -> ...) >>> `catch` (\(e :: PatternMatchFail) -> ...) >> >> I don't think those are equivalent. In the second case, the >> PatternMatchFail handler scopes over the ExitCode handler. > > I think Duncan forgot to write parens. According to Ian's example, > here is an equivalent code. > > (action > `catch` (\(e :: ExitCode) -> ...)) > `catch` (\(e :: PatternMatchFail) -> ...) > > http://www.haskell.org/pipermail/libraries/2008-July/010095.html
That's equivalent to the code without the parentheses, but it isn't equivalent to the code using "catches". Assume we have exitCodeHandler :: ExitCode -> IO () and pattternMatchHandler :: PatternMatchFail -> IO (), 1. action `catches` [ Handler exitCodeHandler, Handler patternMatchHandler ] 2. (action `catch` exitCodeHandler) `catch` patternMatchHandler Let's further assume that "action" throws an ExitCode exception and "exitCodeHandler" throws a PatternMatchFail exception. In example 1, the PatternMatchFail exception thrown by "exitCodeHandler" is not caught by "patternMatchHandler", but it in example 2 it is caught. In other words, patternMatchHandler is active during the evaluation of exitCodeHandler in example 2, but not in example 1. -- Dave Menendez <[EMAIL PROTECTED]> <http://www.eyrie.org/~zednenem/> _______________________________________________ Glasgow-haskell-users mailing list Glasgow-haskell-users@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-users