Hi Greeg, All
I created a repository in gitHub with the necessary code for generating execution traces in case of error:
the code is
{-# 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"
run It with
>runghc Demos/TraceExample.hs
"hello"
"world"
TraceExample.hs: TRACE (error in the last line):
main, Demos.TraceExample(Demos\TraceExample.hs): (23, 18)
main, Demos.TraceExample(Demos\TraceExample.hs): (26, 4)
example, Demos.TraceExample(Demos\TraceExample.hs): (30, 13)
example, Demos.TraceExample(Demos\TraceExample.hs): (32, 15)
exception: Prelude.undefined
to show the generated trace. It is necessary to install the monadloc-pp and the monadloc packages.
It uses Control.Monad.Supervisor which is the monad that execute the backtracking that generate the error trace after the error. ( I will upload it to Hackage soon).
It uses also Control.Monad.Supervisor.Trace, that has a MonadLoc instance for the Supervisor monad. You can create a MonadLogger instance taking as example the MonadLoc one.