<br><br>
<div class="gmail_quote">2009/1/23 Paul Visschers <span dir="ltr"><<a href="mailto:mail@paulvisschers.net">mail@paulvisschers.net</a>></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><...></div></div></blockquote>
<div> </div>
<div>I think I get the polymorphism. What I don'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> </div>
<div>As I tried to explain, I'm probably misled by the comparison with OOP languages, where polymorphism is implemented via interfaces (Java) or abstract classes/methods (C++). For instance in Java you can write:</div>
<div> </div>
<div>AbstractInterface a = new ConcreteClass();</div>
<div> </div>
<div>if ConcreteClass implements AbstractInterface. 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> </div>
<div> </div>
<div>Now, I understand that 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 _actual_ reason behind the formal reason: usually a programming language place</div>
<div>limits to avoid ambiguity or misuse of language feature. </div>
<div> </div>
<div><...></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't use it when you need an<br>
Int or a Double for example.</div>
<div> </div>
<div>This is what I don't get : why yielding an Integer is not good enough for a function</div>
<div>that promises to yield a num? What is missing in Integer?</div>
<div> </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> </div>
<div>You have been clear. I'm probably still too bound to OOP world. Thanks.</div>
<div> </div>
<div> </div>
<div>Ciao</div>
<div>-------</div>
<div>FB</div></div><br>