title: The reason for MonadState get and put?
body: <p>I'm reading the Monads chapter in Real World Haskell (chapter 14).
  A function is <a href="http://book.realworldhaskell.org/read/monads.html#Random.hs:getRandom" rel="noreferrer">defined</a> as follows:</p>
  
  <pre><code>type RandomState a = State StdGen a
  getRandom :: Random a =&gt; RandomState a
  getRandom =
      get &gt;&gt;= \gen -&gt;
      let (val, gen')= random gen in
      put gen' &gt;&gt;
      return val
  </code></pre>
  
  <p>I don't really understand the purpose of the get and put functions here.
  I rewrote the function as following which seems to do the same thing and is more concise:</p>
  
  <pre><code>getRandom2 :: Random a =&gt; RandomState a 
  getRandom2= State $ \ s -&gt; random s
  </code></pre>
  
  <p>So my question is: <strong>What is the purpose of get and put in general?</strong></p>