<html><body><div style="color:#000; background-color:#fff; font-family:times new roman, new york, times, serif;font-size:12pt"><div style="font-family: 'times new roman', 'new york', times, serif; font-size: 12pt; ">Hi.</div><div style="font-family: 'times new roman', 'new york', times, serif; font-size: 12pt; ">I'm trying to write a code which counts the number of &nbsp;'a's &nbsp;in a string.</div><div style="font-family: 'times new roman', 'new york', times, serif; font-size: 12pt; ">it looks like this :</div><div style="font-family: 'times new roman', 'new york', times, serif; font-size: 12pt; "><br></div><div><div><font face="'times new roman', 'new york', times, serif">mycounter st =</font></div><div><font face="'times new roman', 'new york', times, serif"><span class="Apple-tab-span" style="white-space:pre">                </span>if st == [] then 0</font></div><div><font face="'times new roman', 'new york', times, serif"><span class="Apple-tab-span"
 style="white-space: pre; ">                </span>else if head st == 'a' then 1 + mycounter tail st else mycounter tail st</font></div><div><font face="'times new roman', 'new york', times, serif"><br></font></div><div><font face="'times new roman', 'new york', times, serif">but it gives this error :&nbsp;</font></div><div><font face="'times new roman', 'new york', times, serif"><div>ERROR "deneme.hs":19 - Type error in function binding</div><div>*** Term &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; :mycounter</div><div>*** Type &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; : [Char] -&gt; b</div><div>*** Does not match : ([a] -&gt; [a]) -&gt; [Char] -&gt; b</div><div>*** Because &nbsp; &nbsp; &nbsp; &nbsp;: unification would give infinite type</div><div><br></div><div>I have no idea about what I'm doing wrong. Can you help me with this please?</div></font></div></div></div></body></html>