Consider the code below : <div><blockquote style="margin:0 0 0 40px;border:none;padding:0px"><div><div>{-# LANGUAGE MultiParamTypeClasses,FlexibleInstances,FunctionalDependencies,UndecidableInstances,FlexibleContexts  #-}</div>
</div><div><div>class Foo a c | a -&gt; c</div></div><div><div>instance Foo Int Float </div></div><div><div>f :: (Foo Int a) =&gt; Int -&gt; a </div></div><div><div>f = undefined</div></div><div><br></div></blockquote>Now when I see the inferred type of f in ghci </div>
<div><blockquote style="margin:0 0 0 40px;border:none;padding:0px"><div>&gt; :t f</div></blockquote></div><div><blockquote style="margin:0 0 0 40px;border:none;padding:0px"><div>&gt; f :: Int -&gt; Float</div><div><br></div>
</blockquote>Now If I add the following code </div><div><blockquote style="margin:0 0 0 40px;border:none;padding:0px"><div><div>g :: Int -&gt; Float </div><div>g = undefined </div><div><br></div><div>h :: (Foo Int a) =&gt; Int -&gt; a </div>
<div>h = g</div></div></blockquote><div><br></div>I get the error </div><div><blockquote style="margin:0 0 0 40px;border:none;padding:0px"><div>Could not deduce (a ~ Float)</div></blockquote><div><br></div><div>I am not able to understand what has happened here ? The restriction &quot;Foo Int a&quot; should have restricted the type of h to &quot;Int -&gt; Float&quot; as shown in the inferred type of f.</div>
<br clear="all"><div><br></div>- Satvik
</div>