title: Compute next prime number in Haskell
body: <p>I am trying to compute the next closest prime number after a number is entered with Haskell,
  I have coded 2 functions <code>isPrime</code> and <code>nextPrime</code> </p>
  
  <p>Here is my code:</p>
  
  <pre><code>isPrime :: Int -&gt; Bool
  isPrime x   | x &lt; 2          = False
          | otherwise      = prime (2:[3,4..(x-1)])
  where 
      prime (y:z)
          | x &lt; y ^ 2      = True
          | x `mod` y == 0 = False
          | otherwise      = prime z
  
  
  
  nextPrime :: Int -&gt; Int
  nextPrime n | isPrime n == True = n
              | otherwise = nextPrime n
          where
              n = n + 1
  </code></pre>
  
  <p>The problem I have is that I get this error when I run it : <em>*</em> Exception: "&lt;&lt;"loop">>"</p>
  
  <p>I don't know what's wrong, is it an infinite loop?</p>