myLength :: [a] -&gt; Int<br><br>This is the first type signature I 
wrote. And I changed the Int into Num after<br>ghci tell me it&#39;s wrong. 
This type signature still not work. But the standard length<br>function&#39;s
 type signature is this:<br>
length :: [a] -&gt; Int<br><br>I think my type signature is right but 
it&#39;s not. And I can not find the reason.<br><br><div class="gmail_quote">2010/11/11 Chaddaï Fouché <span dir="ltr">&lt;<a href="mailto:chaddai.fouche@gmail.com">chaddai.fouche@gmail.com</a>&gt;</span><br><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
<div><div></div><div class="h5">On Thu, Nov 11, 2010 at 9:24 AM, 贾旭卿 &lt;<a href="mailto:amazingjxq@gmail.com">amazingjxq@gmail.com</a>&gt; wrote:<br>
&gt; This is exercise 3.1 of Real World Haskell. I have my length function like<br>
&gt; this:<br>
&gt;<br>
&gt; myLength [] = 0<br>
&gt; myLength (_:xs) = 1 + (myLength xs)<br>
&gt;<br>
&gt; And I assumed the type signature is like this:<br>
&gt; mylength :: [a] -&gt; Num<br>
&gt;<br>
&gt; But when I wrote this into the file and reloaded it into ghci, there is an<br>
&gt; error.<br>
&gt;&gt;<br>
&gt;&gt;     The type signature for `mylength&#39; lacks an accompanying binding<br>
&gt;&gt; Failed, modules loaded: none.<br>
&gt;<br>
&gt;<br>
&gt; And the type signature given by ghci is<br>
&gt;&gt;<br>
&gt;&gt; myLength :: (Num t1) =&gt; [t] -&gt; t1<br>
&gt;<br>
&gt; So how can I modify the function to have a type signature like the first<br>
&gt; one?<br>
<br>
</div></div>You can&#39;t, since Num isn&#39;t a type, it&#39;s a typeclass.<br>
<br>
&gt; myLength :: (Num b) =&gt; [a] -&gt; b<br>
<br>
means that myLength takes a list of any type and can return any type<br>
that is an instance of Num (Num being the typeclass of numbers, that<br>
means that you can do most things you do on numbers, adding them,<br>
multiplying them, and so on...).<br>
<br>
If you want a simpler type signature, you could use :<br>
<br>
&gt; myLength :: [a] -&gt; Int<br>
<br>
or<br>
<br>
&gt; myLength :: [a] -&gt; Integer<br>
<br>
since Int (32 or 64 bits integer) and Integer are real type that are<br>
instances of the Num typeclass.<br>
<font color="#888888"><br>
--<br>
Jedaï<br>
</font></blockquote></div><br>