[Haskell-beginners] Logging in Haskell

Jason Dusek jason.dusek at gmail.com
Mon Mar 30 20:47:43 EDT 2009


  In general, you can't do it -- there's no way to perform a
  write to external logs in the midst of pure code. That would
  mean it's not pure any more, consequently changing its type
  signature and forcing you to rewrite a bunch of stuff. The
  use of the GHCi debugger is highly recommended.

  The first few times you use the debugger, you'll notice it
  seems to go backward. That is laziness in action -- it goes
  immediately to the result of an expression and then walks
  backward as it is forced to evaluate the intermediate values.

  Well, okay -- there is one way to do the logging like you
  want; but it's dangerous. Use `unsafePerformIO` all over the
  place and pray :)

--
Jason Dusek


 |...GHCi debugger...|
  http://www.haskell.org/ghc/docs/latest/html/users_guide/ghci-debugger.html


More information about the Beginners mailing list