blackholes and exception handling
sebf at informatik.uni-kiel.de
Sat May 1 18:10:23 EDT 2010
GHC can spot (some) non-terminating computations and terminate with
instead of running indefinitely. With exception handling one can
handle such situations. The following program 'launches missiles':
main = do handle go_ahead don't_launch_first
don't_launch_first = don't_launch_first
go_ahead :: SomeException -> IO ()
go_ahead _ = putStr "go ahead, "
launch_missiles = putStr "fire!"
The output of this program is
go ahead, fire!
although, don't_launch_first is a non-terminating computation.
Without black-hole detection this code would never 'launch missiles'.
Is the above output intended?
The idea behind black-hole detection is that one bottom is as good as
another . Consequently, exception handling may not distinguish
between non-termination and other errors.
Is the equation
_|_ `catch` const a = a
supposed to hold in general (for every kind of bottom)? Or is it a bug
in GHC that programmers can handle black-hole errors?
 A semantics for imprecise exceptions
Underestimating the novelty of the future is a time-honored tradition.
More information about the Glasgow-haskell-users