
12 Apr
2009
12 Apr
'09
11:29 p.m.
On Sat, Apr 11, 2009 at 3:16 PM, kaushal Pathak
first_div :: Integral a => a ; first_div = round (sqrt x)
Should in fact be first_div :: Integral a => a ; first_div = round (sqrt $ fromIntegral x) Basically, sqrt has the type signature sqrt :: (Floating a) => a -> a, meaning it only works on things like doubles. The rest of your code only works on integral types. Your code compiles just fine because, in theory, you could have a data structure which in an instance of both Integral and Floating, but the argument you provide is probably just a regular old Int or something like that (I can't be certain, as you have not provided the code that calls isPrime1). Let me know if you'd like further clarification. Michael