title: Convert Maybe Int to Int in Haskell
body: <p>I am working on the following code and wanted to find the index of the number in the box string. So I used <code>findIndex</code> but it returns the <code>Maybe Int</code> value whereas I want only <code>Int</code> value.</p>
  <p>How can I convert <code>Maybe Int</code> to <code>Int</code> value or is there any way in which I can extract <code>Int</code> from <code>Maybe Int</code>. The code should print an error message if <code>Maybe Int</code> is <code>Nothing</code>.</p>
  <pre><code>box:: String
  box = unlines $ [&quot;0 | 1 | 2&quot;,
                   &quot;---------&quot;,
                   &quot;3 | 4 | 5&quot;,
                   &quot;---------&quot;,
                   &quot;6 | 7 | 8&quot;]
  
  moves = do
          putStrLn &quot; Enter the number&quot;
          number &lt;- readLn :: IO Int
          print number
          findpostion number box
  
  findposition number box = findIndex (==number) box
  </code></pre>