title: The state monad and learnyouahaskell.com
body: <p>I was reading <a href="http://learnyouahaskell.com/for-a-few-monads-more#state">Learn You a Haskell's guide on the state monad</a>, but I had trouble understanding it since the stack example couldn't compile. In the guide, he used the following piece of code:</p>
  
  <pre><code>import Control.Monad.State  
  
  type Stack = [Int]
  
  pop :: State Stack Int  
  pop = State $ \(x:xs) -&gt; (x,xs)  
  
  push :: Int -&gt; State Stack ()  
  push a = State $ \xs -&gt; ((),a:xs) 
  </code></pre>
  
  <p>While I understand what it's supposed to do, it won't compile. I have no idea why. The error message is:</p>
  
  <pre><code>Stack.hs:6:7: Not in scope: data constructor `State'
  
  Stack.hs:9:10: Not in scope: data constructor `State'
  </code></pre>
  
  <p>This makes no sense to me, since "State" is, to my knowledge, in fact a data constructor, defined as</p>
  
  <pre><code>newtype State s a = State { runState :: s -&gt; (a,s) }
  </code></pre>
  
  <p>Is the guide "wrong", and if so, how do I fix it?</p>