<font color='black' size='2' face='Arial, Helvetica, sans-serif'>
<div>
<div style="clear: both; ">
<div><font class="Apple-style-span" size="2">
<div>Hello everyone,</div>
<div><span class="Apple-tab-span" style="white-space:pre"> </span>I am just starting with Haskell so please bear with me.</div>
<div><br>
</div>
<div>Here's my question:</div>
<div><br>
</div>
<div>Consider the below definition / output:</div>
<div><br>
</div>
<div>Prelude> :t (+)</div>
<div>(+) :: (Num a) => a -> a -> a</div>
<div><br>
</div>
<div><span class="Apple-tab-span" style="white-space:pre"> </span>What I understand from the above is that "+" is a function that takes two args</div>
<div>which are types of anything that IS-AN instance of "Num" (Int, Integer, Float, Double)</div>
<div>and returns an instance of "Num".</div>
<div>Hence this works fine:</div>
<div>Prelude> 4.3 + 2</div>
<div>6.3</div>
<div><br>
</div>
<div>But I can't understand why this doesn't work:</div>
<div>Prelude> 4.3 + 4 :: Int</div>
<div><br>
</div>
<div><interactive>:1:0:</div>
<div> No instance for (Fractional Int)</div>
<div> arising from the literal `4.3' at <interactive>:1:0-2</div>
<div> Possible fix: add an instance declaration for (Fractional Int)</div>
<div> In the first argument of `(+)', namely `4.3'</div>
<div> In the expression: 4.3 + 4 :: Int</div>
<div> In the definition of `it': it = 4.3 + 4 :: Int</div>
<div><br>
</div>
<div><span class="Apple-tab-span" style="white-space:pre"> </span>I expected that the second addition would work as both "Float" and "Int" are</div>
<div>instances of "Num". Is it that since both the formal args are defined as "a" they</div>
<div>have to be exactly the same instances? Had "+" been defined something like: </div>
<div>(+) :: (Num a, Num b) => a -> b -> a</div>
<div>my second addition would have worked?</div>
<div><br>
</div>
<div>Please let me know what I am missing.</div>
<div><br>
</div>
<div>Regards,</div>
<div>Venu Chakravorty.</div>
</font></div>
</div>
</div>
</font>