Hello,

GHC can spot (some) non-terminating computations and terminate with

    blackhole: <<loop>>

instead of running indefinitely. With exception handling one can handle such situations. The following program 'launches missiles':

    import Control.Exception

    main = do handle go_ahead don't_launch_first
              launch_missiles

    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 [1]. 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?

Sebastian

[1] A semantics for imprecise exceptions
     http://portal.acm.org/citation.cfm?id=301637

--
Underestimating the novelty of the future is a time-honored tradition.
(D.G.)



_______________________________________________
Glasgow-haskell-users mailing list
Glasgow-haskell-users@haskell.org
http://www.haskell.org/mailman/listinfo/glasgow-haskell-users

Reply via email to