title: Haskell "No instance for" error
body: <p>I am trying to write a function that checks if a number is prime. I wrote this : </p>
  
  <pre><code>primeCheck :: Int -&gt; Int -&gt; Bool
  primeCheck n i 
      | n == 2 = True
      | i == 1 = True
      | n `mod` i == 0 = False
      | otherwise = primeCheck n (i -1)
  
  isPrime :: Int -&gt; Bool
  isPrime n = primeCheck n (floor (sqrt n))
  </code></pre>
  
  <p>And I get these errors : </p>
  
  <blockquote>
    <p>No instance for (RealFrac Int)
          arising from a use of <code>floor'
        Possible fix: add an instance declaration for (RealFrac Int)
        In the second argument of</code>primeCheck', namely <code>(floor (sqrt n))'
        In the expression: primeCheck n (floor (sqrt n))
        In an equation for</code>isPrime':
            isPrime n = primeCheck n (floor (sqrt n))</p>
  
  <pre><code>No instance for (Floating Int)
    arising from a use of `sqrt'
  Possible fix: add an instance declaration for (Floating Int)
  In the first argument of `floor', namely `(sqrt n)'
  In the second argument of `primeCheck', namely `(floor (sqrt n))'
  In the expression: primeCheck n (floor (sqrt n)) Failed, modules loaded: none.
  </code></pre>
  </blockquote>
  
  <p>When I change the code to this to hopefully fix the problem:</p>
  
  <pre><code>primeCheck :: Int -&gt; Int -&gt; Bool
  primeCheck n i 
      | n == 2 = True
      | i == 1 = True
      | n `mod` i == 0 = False
      | otherwise = primeCheck n (i -1)
  
  isPrime :: Int -&gt; Bool
  isPrime n = primeCheck n (floor (RealFrac (sqrt  (Floating n))))
  </code></pre>
  
  <p>I get this : </p>
  
  <blockquote>
    <p>Not in scope: data constructor `RealFrac'</p>
    
    <p>Not in scope: data constructor `Floating'</p>
  </blockquote>
  
  <p>How can I fix this? </p>