[Haskell-beginners] Logging in Haskell

Brent Yorgey byorgey at seas.upenn.edu
Mon Mar 30 08:52:19 EDT 2009


On Mon, Mar 30, 2009 at 02:01:55PM +0200, Sergey Mikhanov wrote:
>    Hi community,
>
> As my Haskell programs grow above 100 lines of code, I feel the necessity 
> to trace the execution of them more closely. In imperative languages one 
> may use logging facilities for checking intermediary values of variables, 
> the execution flow, etc. How this usually handled in Haskell (I bet that 
> despite the fact that in Haskell it is relatively easier to write bug-free 
> and checked code, the industrial systems still need some logging being 
> done)?

It depends what you want to do.  If you just want to print out some
intermediate values to do a little debugging, try the 'trace' function
from Debug.Trace.  If you actually want an industrial-strength logging
system, there's the hslogger library:

  http://hackage.haskell.org/cgi-bin/hackage-scripts/package/hslogger

Generally collecting some information while a computation progresses
can be done with the Writer monad, from Control.Monad.Writer.

-Brent


More information about the Beginners mailing list