<html><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><br><div><div>On Feb 25, 2008, at 4:11 PM, Philippa Cowderoy wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite">On Mon, 25 Feb 2008, Ben wrote:<br><br><blockquote type="cite">&lt;interactive&gt;:1:8:<br></blockquote><blockquote type="cite"> &nbsp;&nbsp;Ambiguous type variable `t' in the constraints:<br></blockquote><blockquote type="cite"> &nbsp;&nbsp;&nbsp;&nbsp;`Fractional t' arising from a use of `/' at &lt;interactive&gt;:1:8-10<br></blockquote><blockquote type="cite"> &nbsp;&nbsp;&nbsp;&nbsp;`Integral t' arising from a use of `^' at &lt;interactive&gt;:1:7-15<br></blockquote><blockquote type="cite"> &nbsp;&nbsp;Probable fix: add a type signature that fixes these type variable(s)<br></blockquote><blockquote type="cite"><br></blockquote><br>/ doesn't do integer division, so from there it concludes that you're <br>working with a Fractional type - Haskell never coerces behind your back, <br>so not only the result of / but also its parameters are Fractional. <br><br>^ only works for Integral types. You might consider that a little <br>arbitrary, but hey - it's mostly like that because it's much easier to <br>raise something to an integer power.<br><br>There's no default it can pick that's both Fractional and Integral, so it <br>doesn't know what type the expression should have and it's asking you to <br>tell it ("add a type signature that fixes these type variable(s)"). In <br>practice you won't be able to unless you've got a broken number type <br>handy, but that's the way things go.</blockquote><div><br class="webkit-block-placeholder"></div>Ok, that makes sense. &nbsp;There's no num k that's both Fractional and Integral, where as in the case where I had the number literals, those were two different instances. What's the usual way of working around this? &nbsp;Something like</div><div><br></div><div><font class="Apple-style-span" face="Monaco" size="2"><span class="Apple-style-span" style="font-size: 10px;">(\k -&gt; (1/ fromInteger k) ^ k) 3</span></font></div><div><font class="Apple-style-span" face="Monaco" size="2"><span class="Apple-style-span" style="font-size: 10px;"><br class="webkit-block-placeholder"></span></font></div><div>?</div></body></html>