Is logging really this tuff with Haskell?
Submitted by metaperl on Thu, 11/08/2007 - 3:35pm.
::
I quote: http://programming.reddit.com/info/5ze57/comments
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).
- metaperl's blog
- Login to post comments
[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!