<pre style="font-family: arial,sans-serif;"><font size="2">I have written this code in Haskell which gives an unresolved <br>overloading error.</font></pre>g x = [2] ++ [3,5..truncate(sqrt x)]<br>p n = fp n (g n)
<br>fp n [ ] = True<br>fp n (x:xs) = if (mod n x) == 0 then False else fp n xs<br><br>when I submit g 103 <br>I get:<br><span style="font-weight: bold;">[2,3,5,7,9] :: [Integer]</span><br><br>when I submit: fp 103 (g 103)
<br>I get<br><span style="font-weight: bold;">True :: Bool<br><br></span><span style="font-family: arial,sans-serif;">But when I submit : p 103</span><br>I get<br><span style="font-weight: bold;">ERROR - Unresolved overloading
</span><br style="font-weight: bold;"><span style="font-weight: bold;">*** Type : (RealFrac a, Floating a, Integral a) => Bool</span><br style="font-weight: bold;"><span style="font-weight: bold;">*** Expression : p 103
</span><br style="font-weight: bold;"><br>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.<br><br><pre style="font-family: arial,sans-serif;">What kind of type casting or type definition can I use to fix the error?
</pre><br>Thanks,<br>Crediné Menezes<br><br>