On 16 Nov 2003 22:43:55 +0100 Peter Simons <[EMAIL PROTECTED]> wrote:
> This is definitely the way to go. The 'MonadWriter' class
> provides a very general interface, which often proves to be
> much more useful than just for logging. Especially, when you
> use it to return data types with useful information --
> rather than just strings. And 'mapWriter' gives you much
> flexibility, when it comes to creating glue code to convert
> different types of log events.
> 
> You can use the transforming variant to encapsulate other
> monads, like IO a. Then, running code that is unaware of
> logging requires a call to 'lift', and that's it.

Thanks for the pointer.  I had seen Control.Monad.Writer in the ghc
docs but previously didn't know what is was good for.  I will try to
learn how to use the various monad transformers and see how easy they
are elegant to use in practice.

For debugging (as opposed to logging) Debug.Trace looks good, thanks
to the other poster(s) for mentioning that.

Maybe eventually I will see a need for mapWriter.  As a passing
thought, I wonder how many programmers can read the mapWriterT
documentation:

mapWriterT :: (m (a, w) -> n (b, w')) -> WriterT w m a -> WriterT w' n b

and start pounding the code out?  Anyway, once I get this all sorted
out, I figure my program will have really nice logging, better than
fprintf(stderr, ...) even.


-- 
Ben Escoto

Attachment: pgp00000.pgp
Description: PGP signature

_______________________________________________
Haskell mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/haskell

Reply via email to