How to best add logging/debugging code?

Ben Escoto bescoto at stanford.edu
Sun Nov 16 10:49:36 EST 2003


Hi all, does anyone have any tips on how to insert debugging or
logging statements through a program?  Here are two possibilities:

1.  Use some kind of logging monad.  But then all your types become
    more complicated and it seems you have to use lots of ->'s and
    >>='s instead of ordinary function application.  It seems this can
    make the code much less elegant.

	Also it seems that every time you want to add logging to a
	function, you have to change its type, and then change the type of
	all the functions that call it, etc.  Should it really be this
	complicated?

2.  Use unsafePerformIO or similar.  But then your code is regularly
    defeating the type system, which presumably isn't good.  Also the
    ghc manual has special instructions for compiling code that uses
    unsafePerformIO, intimating that it isn't used very often.

It seems this must come up a lot when writing Haskell programs.  What
do most pople do?


-- 
Ben Escoto
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
Url : http://haskell.org/pipermail/haskell/attachments/20031116/f24a2f55/attachment.bin


More information about the Haskell mailing list