title: How do I do logging in Haskell?
body: <p>I'm attempting to use HSlogger to get some information about my program. So I add the following line to my function </p>
  
  <pre><code>import Data.Word
  import qualified Data.ByteString as B
  import qualified Data.ByteString.Lazy as L
  import Data.Bits
  import Data.Int
  import Data.ByteString.Parser
  
  import System.Log.Logger
  import System.Log.Handler.Syslog
  
  
  importFile :: FilePath -&gt; IO (Either String (PESFile ))
  importFile n = do
       warningM "MyApp.Component2" "Something Bad is about to happen."
       ...
  </code></pre>
  
  <p>And that works fine, because the function is inside IO. 
  However when I add a similar line to the following function:</p>
  
  <pre><code>...
  parsePES :: Parser PESFile
  parsePES = do
          header &lt;- string "#PES"
          warningM "parsing header"
          ...
          return (PESFile ...)
  </code></pre>
  
  <p>I get a type error: </p>
  
  <pre><code> Couldn't match expected type `Parser a0'
                  with actual type `String -&gt; IO ()'
      In the return type of a call of `warningM'
      In a stmt of a 'do' expression: warningM "parsing header"
      In the expression:
        do { header &lt;- string "#PES";
             warningM "parsing header";
          ...
  </code></pre>
  
  <p>And I totally understand why - parsePES is in the Parser monad, not the IO monad.
  What I don't understand is what to do about it. Do I need a monad transformer so I can stack the Parser monad and the IO monad together? How do I go about that?</p>