<div>Hi,</div><div><br></div><div> I found than this piece of code causes an error in GHC ( <b><a href="http://haskell.pastebin.com/m5e3f4a4c">http://haskell.pastebin.com/m5e3f4a4c</a></b> ):</div><div><br></div><div><font class="Apple-style-span" face="'courier new', monospace">data Tree a = Leaf a | Node (Tree a) (Tree a)</font></div>
<div><font class="Apple-style-span" face="'courier new', monospace"><br></font></div><div><font class="Apple-style-span" face="'courier new', monospace">--prettyShow :: (Show a, Num a) => Tree a -> String -- WORKS</font></div>
<div><font class="Apple-style-span" face="'courier new', monospace">prettyShow :: (Num a, Show a) => Tree a -> String -- FAILS</font></div><div><font class="Apple-style-span" face="'courier new', monospace">prettyShow (Leaf a) = show a</font></div>
<div><font class="Apple-style-span" face="'courier new', monospace">prettyShow (Node a b) = (simple a) ++ (simple b)</font></div><div><font class="Apple-style-span" face="'courier new', monospace"><br></font></div>
<div><font class="Apple-style-span" face="'courier new', monospace">simple :: (Show a, Num a) => Tree a -> String</font></div><div><font class="Apple-style-span" face="'courier new', monospace">simple (Leaf x) = prettyShow (Leaf x)</font></div>
<div><font class="Apple-style-span" face="'courier new', monospace">simple x = "(" ++ prettyShow x ++ ")"</font></div><div><br></div><div>With the error:</div><div><font class="Apple-style-span" face="'courier new', monospace">test.lhs:14:0:</font></div>
<div><font class="Apple-style-span" face="'courier new', monospace"> Couldn't match expected type `Show a'</font></div><div><font class="Apple-style-span" face="'courier new', monospace"> against inferred type `Num a1'</font></div>
<div><font class="Apple-style-span" face="'courier new', monospace"> When matching the contexts of the signatures for</font></div><div><font class="Apple-style-span" face="'courier new', monospace"> prettyShow :: forall a. (Num a, Show a) => Tree a -> String</font></div>
<div><font class="Apple-style-span" face="'courier new', monospace"> simple :: forall a. (Show a, Num a) => Tree a -> String</font></div><div><font class="Apple-style-span" face="'courier new', monospace"> The signature contexts in a mutually recursive group should all be identical</font></div>
<div><font class="Apple-style-span" face="'courier new', monospace"> When generalising the type(s) for prettyShow, simple</font></div><div><font class="Apple-style-span" face="'courier new', monospace">Failed, modules loaded: none.</font></div>
<div><br></div><div><br></div><div>But if I change the order of <b>Show</b> and <b>Num</b> in the signature of <i>prettyShow</i> it works.</div><div><br></div><div>It's a GHC problem? it's normal than signature is order-dependent?</div>
<div><br></div><div>I use <b>GHC 6.10.3</b></div><div><br></div><div>Thanks, Luis Cabellos</div><br>-- <br><br>LC, ("There is no Dana, only Zuul." - Cazafantasmas [1984])