Getting debugging/logging info?

In imperative languages we can do this type of thing: SystemLogging.LogInfo("About to do something..."); DoSomething(); SystemLogging.LogInfo("Did Something"); SystemLogging.LogInfo("x is " + x ); How can we do something similar in Haskell?

Hi
SystemLogging.LogInfo("Did Something"); SystemLogging.LogInfo("x is " + x );
How can we do something similar in Haskell?
See trace: http://www.haskell.org/hoogle/?q=trace Thanks Neil

On Jul 2, 2007, at 18:40 , Neil Mitchell wrote:
SystemLogging.LogInfo("Did Something"); SystemLogging.LogInfo("x is " + x );
How can we do something similar in Haskell?
See trace: http://www.haskell.org/hoogle/?q=trace
In addition, you could use the Writer monad to collect log information as you perform a computation. -- brandon s. allbery [solaris,freebsd,perl,pugs,haskell] allbery@kf8nh.com system administrator [openafs,heimdal,too many hats] allbery@ece.cmu.edu electrical and computer engineering, carnegie mellon university KF8NH

"Hugh Perkins"
SystemLogging.LogInfo("About to do something..."); DoSomething(); SystemLogging.LogInfo("Did Something"); SystemLogging.LogInfo("x is " + x );
How can we do something similar in Haskell?
Maybe, with System.IO, main = do log <- openFile "/tmp/log.txt" AppendMode hSetBuffering log LineBuffering hPutStrLn log "About to do something..." x <- return $! product [1 .. 65536] hPutStrLn log "did something." hPutStrLn log ("x is " ++ show x) hClose log Others may now correct me. (-: -- Mark

On 7/3/07, Neil Mitchell
See trace: http://www.haskell.org/hoogle/?q=trace
I'll check that out. Thanks.
Maybe, with System.IO,
Fine in main :-) Less good in a 100,000 line application.

Hugh Perkins wrote:
In imperative languages we can do this type of thing:
SystemLogging.LogInfo("About to do something..."); DoSomething(); SystemLogging.LogInfo("Did Something"); SystemLogging.LogInfo("x is " + x );
This is what the Writer Monad is for, probably. Jules

Ok, I'll play with that.
On 7/3/07, Jules Bean
Hugh Perkins wrote:
In imperative languages we can do this type of thing:
SystemLogging.LogInfo("About to do something..."); DoSomething(); SystemLogging.LogInfo("Did Something"); SystemLogging.LogInfo("x is " + x );
This is what the Writer Monad is for, probably.
Jules
participants (5)
-
Brandon S. Allbery KF8NH
-
Hugh Perkins
-
Jules Bean
-
mark@ixod.org
-
Neil Mitchell