Using DeepSeq for exception ordering

Nicolas Frisby nicolas.frisby at gmail.com
Thu Nov 8 19:01:39 CET 2012


And the important observation is: all of them throw A if interpreted in
ghci or compiled without -O, right?


On Thu, Nov 8, 2012 at 11:24 AM, Albert Y. C. Lai <trebla at vex.net> wrote:

> On 12-11-08 07:12 AM, Simon Hengel wrote:
>
>> I was just going to say that I can give at least one counterexample
>> where this does not hold:
>>
>>    evaluate (('a' : undefined) `deepseq` return () :: IO ())
>>    throwIO exceptionB
>>
>> But then I realized that here exceptionA is optimized away altogether.
>> For me this smells like a bug.  Is this related to [1]?
>>
>> [1] http://hackage.haskell.org/**trac/ghc/ticket/2273<http://hackage.haskell.org/trac/ghc/ticket/2273>
>>
>
> Interesting. A few more tests (all GHC 7.4.2, linux, x86 32-bit, use "ghc
> -O" to compile):
>
> The following cases throw A:
>
> import Control.DeepSeq
> import Control.Exception
>
> main = do
>   evaluate (('a' : error "A") `deepseq` return () :: Maybe ())
>   throwIO (userError "B")
>
> main = do
>   evaluate (('a' : error "A") `deepseq` ())
>   throwIO (userError "B")
>
> main = do
>   evaluate (('a' : error "A") `deepseq` True)
>   throwIO (userError "B")
>
> main = do
>   x <- evaluate (('a' : error "A") `deepseq` putStrLn "hi")
>   x
>   throwIO (userError "B")
>
> The following cases throw B:
>
> main = do
>   evaluate (('a' : error "A") `deepseq` return () :: IO ())
>   throwIO (userError "B")
>
> main = do
>   evaluate (('a' : error "A") `deepseq` putStrLn "hi")
>   throwIO (userError "B")
>
> main = do
>   evaluate (('a' : error "A") `deepseq` getLine)
>   throwIO (userError "B")
>
>
> ______________________________**_________________
> Glasgow-haskell-users mailing list
> Glasgow-haskell-users at haskell.**org <Glasgow-haskell-users at haskell.org>
> http://www.haskell.org/**mailman/listinfo/glasgow-**haskell-users<http://www.haskell.org/mailman/listinfo/glasgow-haskell-users>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/glasgow-haskell-users/attachments/20121108/fea1bdd6/attachment.htm>


More information about the Glasgow-haskell-users mailing list