[web-devel] Automatic error traces

Alberto G. Corona agocorona at gmail.com
Fri Jul 19 00:00:50 CEST 2013


Hi Greeg, All

I created a repository in gitHub with the necessary code for generating
execution traces in case of error:

https://github.com/agocorona/control-monad-supervisor/blob/master/Demos/TraceExample.hs

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.


2013/7/17 Alberto G. Corona <agocorona at gmail.com>

> Hi Greeg.
>
> Nice I will publish the mechanism in a separate package once I clean it up
>
> At first sight, It is possible to use file-location and monad-logger with
> the traces  instead of monadloc. In the meantime, I will advance to you a
> copy of the details in a separate mail.
>
>
> 2013/7/16 Greg Weber <greg at gregweber.info>
>
>> That's great. We should collaborate on this. I wrote the file-location
>> package and Michael Snoyman wrote monad-logger: both of these give file
>> location information. I also added command tracing to Shelly (which could
>> also benefit from this kind of thing) and recently released rollbar for
>> error notification and would like to have as much line info as possible for
>> that.
>>
>>
>> On Tue, Jul 16, 2013 at 5:45 AM, Alberto G. Corona <agocorona at gmail.com>wrote:
>>
>>> It is important to have execution traces in case of error. specially in
>>> server applications that run 24/7 such are web applications
>>>
>>> Thanks to the wonderful package monadloc by Pepe Iborra, now MFlow can
>>> generate a complete execution trace in case of error.
>>>
>>> The control-monad-exception uses monadLoc to generate stack traces, but
>>> MFlow makes use of his backtracking mechanism to generate a complete
>>> execution trace.
>>>
>>> Here I explain what and how:
>>>
>>>
>>> http://haskell-web.blogspot.com.es/2013/07/automatic-error-trace-generation-in.html
>>>
>>> The MFlow version that implements this is in gitHub. Not in hackage yet.
>>>
>>> https://github.com/agocorona/MFlow
>>>
>>> I´m quite proud of it since it is one of the things closest to magic
>>> that I have done.
>>>
>>> Feedback?
>>>
>>> I do not want to keep MFlow as a single person development. I think that
>>> it has many unique and nice features not available in other languages and
>>> frameworks, and it can be raised to a serious exploitation level by
>>> the Haskell community. This will attract people working in Industrial Web
>>> development to Haskell thanks to the edge in expressiveness and safety
>>> necessary for creating industrial solutions that Haskell has over other
>>> languages.
>>>
>>> It uses most other Haskell web developments  blaze, wai, hamlet etc
>>> and there are many other things to come.
>>>
>>> monadLoc : http://hackage.haskell.org/package/monadloc
>>>
>>> --
>>> Alberto.
>>>
>>> _______________________________________________
>>> web-devel mailing list
>>> web-devel at haskell.org
>>> http://www.haskell.org/mailman/listinfo/web-devel
>>>
>>>
>>
>
>
> --
> Alberto.
>



-- 
Alberto.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/web-devel/attachments/20130719/ae65c7f7/attachment.htm>


More information about the web-devel mailing list