Safe Haskell | None |
---|
This module add a MonadLoc
instance to the Supervisor
monad. This instance generates a trace when a
uncaugh exception is raised.
. See the MonadLoc package: http://hackage.haskell.org/package/monadloc
The package control-monad-exception produces call stacks using monadloc
, but the Supervisor
monad
produces execution traces thanks to the backtracking mechanism.
The trace is produced after the exception is raised. So it does not generate overhead in normal execution.
For more finer control of exceptions, ej. for retrowing exceptions managed outside the Supervisor monad , create your own instance
Execute the example at Demos/TraceExample.hs
{-# OPTIONS -F -pgmF MonadLoc #-} module Demos.TraceExample ( ) where import Control.Monad.Loc import Control.Monad.Supervisor.Trace import Control.Monad.Trans main= runTrace $ do liftIO $ print "hello" example example= if True then do liftIO $ print "world" liftIO $ undefined else liftIO $ print "not there"
Produce this trace:
"hello" "world" TraceExample.hs: TRACE (error in the last line): . main, Demos.TraceExample(DemosTraceExample.hs): (23, 18) main, Demos.TraceExample(DemosTraceExample.hs): (26, 4) example, Demos.TraceExample(DemosTraceExample.hs): (30, 13) example, Demos.TraceExample(DemosTraceExample.hs): (32, 15) exception: Prelude.undefined
Documentation
runTrace :: Supervise [String] m => Sup [String] m a -> m (Control a)Source
Execute an Supervisor computation and raise an error with a trace when an uncaugh exception is raised. It is necessary to preprocess the file with the monadloc-pp preprocessor.
Otherwise, it produces the same error with no trace.