This is exercise 3.1 of Real World Haskell. I have my length function like this:<br><br>myLength [] = 0<br>myLength (_:xs) = 1 + (myLength xs)<br><br>And I assumed the type signature is like this:<br>mylength :: [a] -&gt; Num<br>
<br>But when I wrote this into the file and reloaded it into ghci, there is an error.<br><blockquote style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;" class="gmail_quote">    The type signature for `mylength&#39; lacks an accompanying binding<br>
Failed, modules loaded: none.<br></blockquote><div> </div><div>And the type signature given by ghci is <br><blockquote style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;" class="gmail_quote">
myLength :: (Num t1) =&gt; [t] -&gt; t1<br></blockquote><div><br>So how can I modify the function to have a type signature like the first one?<br></div> </div><div> </div><br><br> <br>