title: How to combine two different monads
body: <p>I'm testing a REST server. I hit it in the IO monad and simulate it in <code>State Db</code> where <code>Db</code> tracks the supposed state of the server. The following function is supposed to run both versions and compare the results...</p>
  
  <pre><code>check :: (Eq a, MonadState d s) =&gt; s a -&gt; IO a -&gt; s (IO Bool)
  -- or: check :: (Eq a, MonadState d s, MonadIO i) =&gt; s a -&gt; i a -&gt; s (i Bool)
  check _ _ = (return.return) False -- for now
  </code></pre>
  
  <p>but when I try it with these simplest possible functions ...</p>
  
  <pre><code>simReset :: State Db ()
  realReset :: IO ()
  
  reset :: StateT Db IO Bool
  reset = check simReset realReset
  </code></pre>
  
  <p>I get this error:</p>
  
  <pre><code>Couldn't match expected type `Bool' with actual type `IO Bool'
  Expected type: StateT Db IO Bool
    Actual type: StateT Db IO (IO Bool)
  In the return type of a call of `check'
  In the expression: check simReset realReset
  </code></pre>
  
  <p>Why? And how do I fix it?</p>
  
  <p>(This topic started here: <a href="https://stackoverflow.com/questions/27200132/lift-to-fix-the-inside-of-a-monad-transformer-stack">Lift to fix the *inside* of a monad transformer stack</a>)</p>