[Haskell-beginners] Need Help

Rahul Kapoor rk at trie.org
Sun Apr 12 23:45:33 EDT 2009


>  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?


More information about the Beginners mailing list