Is logging really this tuff with Haskell?

Submitted by metaperl on Thu, 11/08/2007 - 3:35pm.

I quote:

Haskell is too weird for me (if I want to add a logging statement, I don't want to rewrite ten functions to use monads instead of the types they previously had).

Submitted by graham.fawcett on Tue, 11/20/2007 - 12:38pm.

[Reading some of your other posts, I wonder whether this post was tongue-in-cheek. I'll comment anyway...]

No, it's a misinformed statement. Even as a Haskell non-expert, it's clear from a quick scan of the libraries that the Debug.Trace module covers the "logging statement" case perfectly, without monads or changing any type signatures.

The lower-level unsafePerformIO function (on which Debug.Trace is presumably based) lets you inject arbitrary I/O into your pure-functional code, at the cost of losing safety from side-effects. But in the case of debugging output, there's no danger here.

So pepper your Haskell code with logging statements, and enjoy!

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.