Here is what I'm trying to do:

isPrime :: Int -> Bool
isPrime x = all (\y -> x `mod` y /= 0) [3, 5..floor(sqrt x)]

(I know I'm not checking for division by two--please ignore that.) Here's what I get:

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 x)'
In the expression: floor (sqrt x)
In the second argument of `all', namely `[3, 5 .. floor (sqrt x)]'

I've spent literally hours trying everything I can think of to make this list using some variant of sqrt, including nonsense like

intSqrt :: Int -> Int
intSqrt x = floor (sqrt (x + 0.0))

It seems that (sqrt 500) works fine but (sqrt x) insists on x being a Floating (why?), and there is no function I can find to convert an Int to a real (why?).

I don't want a method to test primality, I want to understand how to fix this. Why is this so hard?

Edit
Report