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?
Thanks,
Crediné Menezes