
#13348: Consider making throw and throwIO strict -------------------------------------+------------------------------------- Reporter: dfeuer | Owner: (none) Type: feature | Status: new request | Priority: normal | Milestone: 8.4.1 Component: Core | Version: 8.1 Libraries | Keywords: | Operating System: Unknown/Multiple Architecture: | Type of failure: Other Unknown/Multiple | Test Case: | Blocked By: Blocking: | Related Tickets: Differential Rev(s): | Wiki Page: -------------------------------------+------------------------------------- It's possible for code to throw an exception that itself throws an imprecise exception. Such an exception is tricky to catch. For example: {{{#!hs import Control.Exception strange = throwIO (undefined :: SomeException) `catch` \ex -> case () of _ | Just _ <- (fromException ex :: Maybe IOError) -> print "IOError" | otherwise -> print "Something else" }}} You might think that this would catch the exception and print "Something else", but in fact it does not. If others think this is as surprising as I do, perhaps we should make `throwIO` and `throw` strict, so an exception will never itself be bottom. Using {{{#!hs throwIO' !e = throwIO e }}} in the code above instead of `throwIO` allows the exception to be caught. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/13348 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler