title: Manipulating Haskell Monad State
body: <p>Somewhat similar to <a href="https://stackoverflow.com/questions/54603200/haskell-monad-state-example">this question</a>, I'm trying to figure out
  how to move around a Haskell Monad state.
  Each <code>Employee</code> in a team is replaced with a corresponding <code>Employee'</code>
  while maintaining some simple state. Here is the code:</p>
  
  <pre><code>module Main( main ) where
  import Control.Monad.State
  
  data Employee  = EmployeeSW  Int Int | EmployeeHW Int String deriving ( Show )
  data Employee' = EmployeeSW'     Int | EmployeeHW'    String deriving ( Show )
  
  scanTeam :: [Employee] -&gt; State (Int,Int) [Employee']
  scanTeam [    ] = return []
  scanTeam (p:ps) = scanEmployee p -- : scanTeam ps ???
  
  scanEmployee :: Employee -&gt; State (Int,Int) Employee'
  scanEmployee (EmployeeSW id s) = do
      (num,raise) &lt;- get
      put (num+1,raise)
      return (EmployeeSW' (s+raise))
  scanEmployee (EmployeeHW id s) = do
      (num,raise) &lt;- get
      put (num+1,raise)
      return (EmployeeHW' (s++(show raise)))
  
  startState = (0,3000)
  
  t = [(EmployeeHW 77 "Hundred"),(EmployeeSW 66 500),(EmployeeSW 32 200)]
  
  main = print $ evalState (scanTeam t) startState
  </code></pre>
  
  <p>I want to eventually concatenate <code>scanEmployee p</code> with <code>scanTeam ps</code>,
  so I tried to extract the pieces of <code>scanEmployee p</code> and somehow glue
  them together with <code>scanTeam ps</code>. So far I failed miserably.
  Actually, I'm not even sure the state can be moved around between them (?).</p>