title: Getting state in a stateful monad supporting exceptions
body: <p>I'm trying to figure out how to solve the following problem:
  I want a monad that behaves like <code>State</code> and <code>Except</code>, so I wrote something like this:</p>
  
  <pre><code>type ExceptStateM s m a = ExceptT String (StateT s m) a
  </code></pre>
  
  <p>Suppose we don't want to wrap another monad and the state is an <code>Int</code>, so we get a monad like this:</p>
  
  <pre><code>type MyMonad a = ExceptStateM Int Identity
  </code></pre>
  
  <p>What I'm wondering now is how to get the state from this monad, because the following code:</p>
  
  <pre><code>foo :: MyMonad Int
  foo = do
      state &lt;- get
      return ()
  </code></pre>
  
  <p>doesn't compile, with the following error:</p>
  
  <pre><code>Couldn't match expected type ‘ExceptT
                                  String (StateT Int Identity) t0’
              with actual type ‘StateT s0 m0 s0’
  In a stmt of a 'do' block: state &lt;- get
  In the expression:
    do { state &lt;- get;
         return () }
  </code></pre>
  
  <p>I would appreciate some hints on where to look</p>