title: Reading numbers from input Haskell
body: <p>I want to have a function that reads arbitrary int's until the number '0' is inserted, and then presents the numbers inserted in an ordered list.</p>
  
  <p>For that i wrote this function:</p>
  
  <pre><code>import Data.List
  
  readIntegers :: IO()
  readIntegers = do
      putStrLn "insert a number: "
      num&lt;-getLine
      let list = ordList ((read num :: Int):list)
      if (read num == 0)  
      then print list 
      else readIntegers
    where ordList ::[Int]-&gt;[Int]
          ordList [] = []
          ordList xs = sort xs
  </code></pre>
  
  <p>This compiles just fine, but when i insert the number '0', it gives me this error:</p>
  
  <pre><code>*** Exception: &lt;&lt;loop&gt;&gt;
  </code></pre>
  
  <p>What am i doing wrong ?</p>