> I'm not quite sure, whether this is a bug at all, so maybe someone can
> explain this behaviour to me:
>
>
> Consider the following piece of code:
>
> \begin{code}
> import Exception
>
> foo = do
> res <- tryAll (someObscureComputationThatThrowsErrors)
> putStr "This is immediately printed: "
> print res -- here res gets evaluated (which usually takes some time)
> -- and the error occurs despite the `tryAll'
>
>
> someObscureComputationThatThrowsErrors :: (Int,Int)
> someObscureComputationThatThrowsErrors = runST $
> -- ...
> if condition
> then return (1,1)
> else error "BANG"
>
>
> main = foo
> \end{code}
>
> The above code (i.e., the code, from where this example is
> derived) lets the
> program die with error "BANG" (if condition is False),
> although there is a
> `tryAll' statement, that should catch these errors!
I tried something similar, but couldn't reproduce the problem. Could you
send us the code?
If you embed the (error "BANG") inside a data structure, then it can indeed
excape from the tryAll because seq only evaluates to WHNF.
eg.
tryAll [error "BANG!"]
will return (Right [error "BANG!"]), and
tryAll (runST (return (error "BANG!")))
will return (Right (error "BANG!")), because return isn't strict.
but
tryALl (runST (error "BANG!"))
will return (Left (ErrorCall "BANG!")).
Cheers,
Simon