module Narc.Debug where
import Prelude hiding (catch)
import Control.Exception (catch, evaluate, throwIO, SomeException)
import Debug.Trace (trace)
import Foreign (unsafePerformIO)
debugFlag :: Bool
debugFlag = False
debug :: String -> a -> a
debug str = if debugFlag then trace str else id
breakFlag x = x
forceAndReport :: a -> String -> a
forceAndReport expr msg =
unsafePerformIO $
catch (evaluate $
expr `seq` expr
) (\(exc::SomeException) ->
breakFlag $
debug msg $
Control.Exception.throwIO exc
)