
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]?
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")