<html><head></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; ">Why am I getting this error:<div><br></div><div><div></div></div><blockquote type="cite"><div><div><font class="Apple-style-span" face="'Courier New'">&nbsp; &nbsp; Couldn't match expected type `Integer' against inferred type `Int'</font></div><div><font class="Apple-style-span" face="'Courier New'">&nbsp; &nbsp; In the expression: foldl step 0 xs</font></div><div><font class="Apple-style-span" face="'Courier New'">&nbsp; &nbsp; In the definition of `asInt_foldAux':</font></div><div><font class="Apple-style-span" face="'Courier New'">&nbsp; &nbsp; &nbsp; &nbsp; asInt_foldAux xs</font></div><div><font class="Apple-style-span" face="'Courier New'">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; = foldl step 0 xs</font></div><div><font class="Apple-style-span" face="'Courier New'">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; where</font></div><div><font class="Apple-style-span" face="'Courier New'">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; step acc '.' = error "cannot handle decimal numbers"</font></div><div><font class="Apple-style-span" face="'Courier New'">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; step acc x = acc * 10 + digitToInt x</font></div></div></blockquote><div><br></div><div>for this code?</div><div><br></div><div><div></div></div><blockquote type="cite"><div><div><font class="Apple-style-span" face="'Courier New'">import Data.Char (digitToInt)</font></div><div><font class="Apple-style-span" face="'Courier New'"><br></font></div><div><font class="Apple-style-span" face="'Courier New'">asInt_fold :: String -&gt; Integer</font></div><div><font class="Apple-style-span" face="'Courier New'">asInt_fold ('-':xs) = -(asInt_foldAux xs)</font></div><div><font class="Apple-style-span" face="'Courier New'">asInt_fold xs &nbsp; &nbsp; &nbsp; = asInt_foldAux xs</font></div><div><font class="Apple-style-span" face="'Courier New'"><br></font></div><div><font class="Apple-style-span" face="'Courier New'">asInt_foldAux :: String -&gt; Integer</font></div><div><font class="Apple-style-span" face="'Courier New'">asInt_foldAux xs = foldl step 0 xs</font></div><div><font class="Apple-style-span" face="'Courier New'">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;where step acc '.' = error "cannot handle decimal numbers"</font></div><div><font class="Apple-style-span" face="'Courier New'">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;step acc x = acc * 10 + digitToInt x</font></div></div></blockquote><div><br></div><div>Note that I'm using <font class="Apple-style-span" face="'Courier New'">Int</font>, rather than <font class="Apple-style-span" face="'Courier New'">Integer</font>, to avoid silent overflow errors.</div><div><br></div></body></html>