Control.Exception

David Menendez dave at zednenem.com
Mon Nov 3 17:40:50 EST 2008


On Mon, Nov 3, 2008 at 12:53 PM, Duncan Coutts
<duncan.coutts at worc.ox.ac.uk> wrote:
> On Mon, 2008-11-03 at 09:26 -0800, Sigbjorn Finne wrote:
>> One way to do this now is to use Control.Exception.catches:
>>
>>  catches :: IO a -> [Handler a] -> IO a
>>  data Handler a where
>>     Handler :: forall a e. (Exception e) => (e -> IO a) -> Handler a
>
> 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.

-- 
Dave Menendez <dave at zednenem.com>
<http://www.eyrie.org/~zednenem/>


More information about the Glasgow-haskell-users mailing list