title: trouble with state monad composition
body: <p>I was trying out the example given at <a href="http://www.haskell.org/haskellwiki/State_Monad#Complete_and_Concrete_Example_1" rel="nofollow">http://www.haskell.org/haskellwiki/State_Monad#Complete_and_Concrete_Example_1</a></p>
  
  <p>How this makes the solution composible is beyond my understanding. Here is what I tried but I get compile errors as follows:</p>
  
  <pre><code>Couldn't match expected type `GameValue -&gt; StateT GameState Data.Functor.Identity.Identity b0'
              with actual type `State GameState GameValue'
  In the second argument of `(&gt;&gt;=)', namely `g2'
  In the expression: g1 &gt;&gt;= g2
  In an equation for `g3': g3 = g1 &gt;&gt;= g2
  Failed, modules loaded: none.
  </code></pre>
  
  <p>Here is the code: See the end lines</p>
  
  <pre><code>module StateGame where
  import Control.Monad.State
  
  type GameValue = Int
  type GameState = (Bool, Int)
  
  -- suppose I want to play one game after the other
  g1 = playGame "abcaaacbbcabbab"
  g2 = playGame "abcaaacbbcabb"
  g3 = g1 &gt;&gt;= g2
  
  m2 = print $ evalState g3 startState
  
  playGame :: String -&gt; State GameState GameValue
  playGame []     = do
      (_, score) &lt;- get
      return score
  
  playGame (x:xs) = do
      (on, score) &lt;- get
      case x of
           'a' | on -&gt; put (on, score + 1)
           'b' | on -&gt; put (on, score - 1)
           'c'      -&gt; put (not on, score)
           _        -&gt; put (on, score)
      playGame xs
  
  startState = (False, 0)
  
  main str = print $ evalState (playGame str) startState
  </code></pre>