
12 Apr
2009
12 Apr
'09
11:45 p.m.
Here is a very simple haskell program I have written to find whether a number is prime or not, which doesn't give me any compilation error but gives following run-time error :
The type of isPrime1 function you have defined is inferred to be isPrime1 :: (Integral a, RealFrac a, Floating a) => a -> IO () You can check this quickly using :t isPrime1 in GHCI. When you try to run isPrime1 in GHCI you get a compile error since the argument isPrime1 is an integer which does not satisfy the three constraints (Integral, RealFrac and Floating). You probably wanted to define isPrime1 to have the type (Integer a) => a -> IO () Cheers, Rahul www.artquiver.com What kind of art do you like?