isPrime :: (Integral a) => a -> Bool
isPrime n | n > 1 = isPrime' n 1 (floor (sqrt n))
isPrime' :: (Integral a) => a -> a -> a -> Bool
isPrime' n 1 x | x <= 1 = True
isPrime' n 1 x = if n `rem` x == 0 then False else isPrime' n 1 (x - 1)
Prelude> :l prob03
Compiling Main ( prob03.hs, interpreted )
prob03.hs:2:34:
Could not deduce (RealFrac a) from the context (Integral a)
arising from use of `floor' at prob03.hs:2:34-38
Probable fix: add (RealFrac a) to the type signature(s) for `isPrime'
In the third argument of `isPrime'', namely `(floor (sqrt n))'
In a right-hand side of function `isPrime': isPrime' n 1 (floor (sqrt n))
In the definition of `isPrime':
isPrime n | n > 1 = isPrime' n 1 (floor (sqrt n))
prob03.hs:2:41:
Could not deduce (Floating a) from the context (Integral a)
arising from use of `sqrt' at prob03.hs:2:41-44
Probable fix: add (Floating a) to the type signature(s) for `isPrime'
In the first argument of `floor', namely `(sqrt n)'
In the third argument of `isPrime'', namely `(floor (sqrt n))'
In a right-hand side of function `isPrime': isPrime' n 1 (floor (sqrt n))
Failed, modules loaded: none.