title: State Monad ExampleProblem
body: <p>I am working on this problem and had previously asked related question. <a href="https://stackoverflow.com/questions/9076881/implementation-of-state-monad">Implementation of State Monad</a> To further refine my code i tried to implement it using only one increment function. </p>
  
  <pre><code>module StateExample where
  import Control.Monad.State
  
  data GlobState = GlobState { c1 :: Int, c2:: Int, c3:: Int} deriving (Show)
  
  newGlobState:: GlobState
  newGlobState = GlobState { c1=0,c2=0,c3=0 }
  
  incr :: String-&gt; State GlobState ()
  incr x = do
       modify(\g -&gt; g {x =x g + 1})
  
  main:: IO()
  main =  do
      let a1= flip execState newGlobState $ do
          incr c1
          incr c2
          incr c1
      print a
  </code></pre>
  
  <p>But here i am getting an error</p>
  
  <pre><code>`x' is not a (visible) constructor field name
  </code></pre>
  
  <p>How can i remove this error?</p>