<div dir="ltr"><div>In ghci try this:<br><br>&gt; examples :: [Int]<br><br></div>It is enough that a is mentioned in the type of every function so that the compiler can figure out which instance is required when it is used.  In size you have to pass an a in to figure out what type it is, but in examples, it is enough to know that it is a list of a&#39;s.<br>
</div><div class="gmail_extra"><br><br><div class="gmail_quote">On Tue, Sep 10, 2013 at 1:59 PM, Carmine Moleti <span dir="ltr">&lt;<a href="mailto:carmine.moleti@gmail.com" target="_blank">carmine.moleti@gmail.com</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi to everyone,<br>
<br>
I&#39;m learning Haskell going through Thompson&#39;s craft of functional<br>
programming (3rd ed).<br>
<br>
As of now I&#39;ve reached Chapter 13 where classes definition and instances are<br>
discussed.<br>
<br>
At some point the &quot;Info a&quot; class is introduced which has the following<br>
interface:<br>
<br>
class Info a where<br>
  examples :: [a]<br>
  size :: a -&gt; Int<br>
<br>
then it goes on explaining that every instance of that class must comply to<br>
the interface shown. So far so good.<br>
<br>
My perplexities start when actual instances are implemented.<br>
<br>
Take, for example the following one:<br>
<br>
instance Info Int where<br>
  examples = [-100..100]<br>
  size _ = 1<br>
<br>
I promptly tried to fiddle with this via ghci and while I was able to access<br>
the &quot;size&quot; function of the interface I have no clue about how to reach the<br>
&quot;examples&quot; part and that prevents me from understanding the next<br>
step when an instance of &quot;Info [a]&quot; is discussed.<br>
About that I don&#39;t quite get the definition of its &quot;examples&quot;, and the<br>
reasons it is defined taking into accounts &quot;all the one and two element<br>
lists that can be built up from exmaples of type a&quot; (cit.)<br>
<br>
Can anyone shed some light about this, please?<br>
<br>
Thanks in advance for your help.<br>
<br>
Best regards,<br>
Carmine<br>
<br>
<br>
<br>
_______________________________________________<br>
Beginners mailing list<br>
<a href="mailto:Beginners@haskell.org">Beginners@haskell.org</a><br>
<a href="http://www.haskell.org/mailman/listinfo/beginners" target="_blank">http://www.haskell.org/mailman/listinfo/beginners</a><br>
</blockquote></div><br></div>