<br><br>
<div class="gmail_quote">2009/1/23 Paul Visschers <span dir="ltr">&lt;<a href="mailto:mail@paulvisschers.net">mail@paulvisschers.net</a>&gt;</span><br>
<blockquote class="gmail_quote" style="PADDING-LEFT: 1ex; MARGIN: 0px 0px 0px 0.8ex; BORDER-LEFT: #ccc 1px solid">
<div>
<div></div>
<div class="Wj3C7c">Hello,<br><br>It seems like you have some trouble with grasping the concept of<br>polymorphism in this particular case.<br><br>&lt;...&gt;</div></div></blockquote>
<div>&nbsp;</div>
<div>I think I get the polymorphism. What I don&#39;t get is why a specialized type cannot</div>
<div>replace a more generic type, since the specialized type implements the interface</div>
<div>defined in the generic type. </div>
<div>&nbsp;</div>
<div>As I tried to explain, I&#39;m probably misled by the&nbsp;comparison with&nbsp; OOP languages, where polymorphism is implemented via interfaces (Java) or abstract classes/methods&nbsp;(C++). For instance in Java you can write:</div>

<div>&nbsp;</div>
<div>AbstractInterface&nbsp;a = new ConcreteClass();</div>
<div>&nbsp;</div>
<div>if ConcreteClass implements AbstractInterface.&nbsp;The complier will handle a as an instance of AbstractInterface, ignoring</div>
<div>anything that is not specifed in its declaration. This make the substitution safe: for instance calling </div>
<div>a.AbstractInterfaceMethod() is fine, while calling a.ConcreteClassMethod() gives you an error.</div>
<div>&nbsp;</div>
<div>&nbsp;</div>
<div>Now, I understand that&nbsp;this is not the case in haskell, and I understand the formal reason you give for this.</div>
<div>What I am trying to understand is the&nbsp;_actual_ reason behind the formal reason: usually a&nbsp;programming language place</div>
<div>limits to avoid ambiguity or misuse of language feature. </div>
<div>&nbsp;</div>
<div>&lt;...&gt;</div>
<div><br>The problem comes from the extra type annotation:<br>a = 3 :: Integer<br>Which says that instead of being of any numeric type, a is of type<br>Integer. This is less general, since you can&#39;t use it when you need an<br>
Int or a Double for example.</div>
<div>&nbsp;</div>
<div>This is what I don&#39;t get : why&nbsp;yielding an&nbsp;Integer is not&nbsp; good enough for a function</div>
<div>that promises to yield a num?&nbsp; What is missing in Integer?</div>
<div>&nbsp;</div>
<blockquote class="gmail_quote" style="PADDING-LEFT: 1ex; MARGIN: 0px 0px 0px 0.8ex; BORDER-LEFT: #ccc 1px solid">
<div>
<div class="Wj3C7c"><span id=""></span><br><br>I hope I explained it clearly. If not please reply.<br><br>Paul<br></div></div></blockquote>
<div>&nbsp;</div>
<div>You have been clear. I&#39;m probably still too bound to OOP world. Thanks.</div>
<div>&nbsp;</div>
<div>&nbsp;</div>
<div>Ciao</div>
<div>-------</div>
<div>FB</div></div><br>