How does caller choose which particular instance of Num they want?<br><br>In object-oriented language If function return type is an interface it means that it can return any implementation of this interface, but caller can&#39;t choose which particular inplementation they want.
<br><br><br>What the difference between haskell class and interface in object-oriented languge such Java or C#?<br><br><div><span class="gmail_quote">2008/1/21, Brent Yorgey &lt;<a href="mailto:byorgey@gmail.com">byorgey@gmail.com
</a>&gt;:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><br><div class="gmail_quote">2008/1/21 Alexander Seliverstov &lt;<a href="mailto:seliverstov.a@gmail.com" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">
seliverstov.a@gmail.com</a>&gt;:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><div><span class="e" id="q_1179d0507a396e2b_1">
<p>Hi, I try to undestand why this code dosen&#39;t work</p>



<p>f :: (Num a)=&gt;Integer-&gt;a</p>

<p>f i = i</p>







<p>Integer is an instance of Num, so why does this code
produce error: &quot;Couldn&#39;t<span>&nbsp; </span>match
expected type &#39;a&#39; againsta inferred type &#39;Integer&#39; ...&quot;</p></span></div>
</blockquote>But the type of this function says that it can return *any* instance of Num -- that is, the caller gets to choose which particular instance of Num they want.&nbsp; This function can only ever return an Integer.<br>

<br>There is actually a function of this type, however; it&#39;s called fromIntegral.&nbsp; It works because it is a member of the Num type class.<br><br>-Brent<br></div>
</blockquote></div><br clear="all">