title: Using Data.Machine, how can you compose two ProcessT together that modifies two different states?
body: <p>Let's say I have a process that modifies an underlying state that is an <code>Int</code>:</p>
  
  <pre><code>p1 :: ProcessT (State Int) Int Int
  p1 = repeatedly $ do
     a &lt;- await
     lift . modify $ (+a)
     yield a
  </code></pre>
  
  <p>And another that modifies an underlying state that is an <code>[Int]</code>:</p>
  
  <pre><code>p2 :: ProcessT (State [Int]) Int Bool
  p2 = repeatedly $ do
     a &lt;- await
     lift . modify $ (++[a])
     as &lt;- get
     if length as &gt; 3 then yield True else yield False
  </code></pre>
  
  <p>I want to compose them this way:</p>
  
  <pre><code>p3 = source [1...6] ~&gt; p1 ~ p2
  </code></pre>
  
  <p>And run them like:</p>
  
  <pre><code>flip runState 0 . flip runState [] . runT $ p3
  </code></pre>
  
  <p>But I get this error: </p>
  
  <pre><code>   Couldn't match expected type `Int' with actual type `[Int]'
     Expected type: ProcessT (State Int) Int c0
     Actual type: ProcessT (State [Int]) Int Bool
     In the second argument of `(~&gt;)', namely `p2'
     In the expression: source [1 .. 6] ~&gt; p1 ~&gt; p2
  </code></pre>
  
  <p>Suggesting p1 and p2 should have the same type of underlying state. In fact, a little experiment shows that p1 and p2 are in fact modifying the <strong>same</strong> underlying state. How can I sidestep this?</p>