[Haskell-cafe] unresolved overloading

Crediné Menezes credine at gmail.com
Thu Jul 12 09:48:04 EDT 2007

I have written this code in Haskell which gives an unresolved
overloading error.

g x             = [2] ++ [3,5..truncate(sqrt x)]
p  n            = fp n (g  n)
fp n [ ]        = True
fp n  (x:xs)  = if (mod n x) == 0 then False else fp n xs

when I submit   g 103
I get:
[2,3,5,7,9] :: [Integer]

when I submit: fp 103 (g 103)
I get
True :: Bool

But when I submit : p 103
I get
ERROR - Unresolved overloading
*** Type       : (RealFrac a, Floating a, Integral a) => Bool
*** Expression : p 103

I know why, there is no type that is at the same time: RealFrac, Floating
and Integral;  but I don´t know how to solve.

What kind of type casting or type definition can I use to fix the error?

Crediné Menezes
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20070712/a1ee180f/attachment.htm

More information about the Haskell-Cafe mailing list