title: How to get normal value from IO action in Haskell
body: <p>I have the following function:</p>
  <pre><code>get :: Chars -&gt; IO Chars
  get cs = do
      char &lt;- getChar
      let (dats, idx) = (curData cs, curIndex cs)
      let (x,y:xs) = splitAt idx dats
      let replacement = x ++ (ord char) : xs
      return $ Chars replacement idx
  </code></pre>
  <p>and I'd like to get a <code>Chars</code> value out of it, <em>not</em> an <code>IO</code> action. I have <em>no</em> idea how to do this, or if it is even possible.</p>
  <p>The <code>Chars</code> type is basically just a container:</p>
  <pre><code>data Chars = Chars {
                 curData  :: [Int],
                 curIndex :: Int
                 -- etc.
               }
  </code></pre>
  <p>The specifics aren't that important, I just want to know if there's a way for this function to return a <code>Chars</code> instead of an <code>IO Chars</code>.</p>
  <p>If not, how do I pass this as an argument to a function that takes a <code>Chars</code>? I'm kind of new to Haskell I/O, but I don't think I want all of my functions that take <code>Chars</code> as arguments to instead have to take <code>IO Chars</code> as arguments, and then extract and repackage them. It seems unnecessary.</p>
  <p>Thanks!</p>