Hi all,<div><br></div><div>I was trying to do something very simple with GADTs when I ran into this problem -</div><div><br></div><blockquote class="webkit-indent-blockquote" style="margin: 0 0 0 40px; border: none; padding: 0px;">

<div><div><font class="Apple-style-span" face="&#39;courier new&#39;, monospace">-- My datatype</font></div><div><font class="Apple-style-span" face="&#39;courier new&#39;, monospace">data T o where</font></div></div><div>

<div><font class="Apple-style-span" face="&#39;courier new&#39;, monospace">  Only ∷ o → T o</font></div></div><div><div><font class="Apple-style-span" face="&#39;courier new&#39;, monospace">  TT ∷ T o1 → (o1 → o2) → T o2</font></div>

</div><div><div><font class="Apple-style-span" face="&#39;courier new&#39;, monospace"><br></font></div></div><div><font class="Apple-style-span" face="&#39;courier new&#39;, monospace">-- Show instance for debugging</font></div>

<div><div><font class="Apple-style-span" face="&#39;courier new&#39;, monospace">instance Show o ⇒ Show (T o) where</font></div></div><div><div><font class="Apple-style-span" face="&#39;courier new&#39;, monospace">  show (Only o) = &quot;Only &quot; ⊕ (show o)</font></div>

</div><div><div><font class="Apple-style-span" face="&#39;courier new&#39;, monospace">  show (TT t1 f) = &quot;TT (&quot; ⊕ (show t1) ⊕ &quot;)&quot;</font></div></div></blockquote><div><br></div><div>When I try to compile this I get the following -</div>

<div><br></div><blockquote class="webkit-indent-blockquote" style="margin: 0 0 0 40px; border: none; padding: 0px;"><div><div><font class="Apple-style-span" face="&#39;courier new&#39;, monospace">Could not deduce (Show o1) arising from a use of `show&#39;</font></div>

</div><div><div><font class="Apple-style-span" face="&#39;courier new&#39;, monospace">    from the context (Show o)</font></div></div></blockquote><font class="Apple-style-span" face="&#39;courier new&#39;, monospace"><span class="Apple-style-span" style="font-family: arial; "><div>

<font class="Apple-style-span" face="&#39;courier new&#39;, monospace"><span class="Apple-style-span" style="font-family: arial; "><br></span></font></div><div><font class="Apple-style-span" face="&#39;courier new&#39;, monospace"><span class="Apple-style-span" style="font-family: arial; "><br>

</span></font></div>While I understand why I get this error, I have no idea how to fix it! I cannot put a Show constraint on o1 because that variable is not exposed in the type of the expression.<br></span></font><div><font class="Apple-style-span" face="&#39;courier new&#39;, monospace"><span class="Apple-style-span" style="font-family: arial; "><br>

</span></font></div><div><font class="Apple-style-span" face="&#39;courier new&#39;, monospace"><span class="Apple-style-span" style="font-family: arial; ">I can work around this by changing my data type declaration to include Show constraints but I don&#39;t want to restrict my data type to only Showable things just so I could have a &quot;Show&quot; instance for debugging -</span></font></div>

<div><font class="Apple-style-span" face="&#39;courier new&#39;, monospace"><span class="Apple-style-span" style="font-family: arial; "><br></span></font></div><blockquote class="webkit-indent-blockquote" style="margin: 0 0 0 40px; border: none; padding: 0px;">

<div><font class="Apple-style-span" face="&#39;courier new&#39;, monospace"><div>Only ∷ Show o ⇒ o → T o</div></font></div><div><font class="Apple-style-span" face="&#39;courier new&#39;, monospace"><div>TT ∷ (Show o1, Show o2) ⇒ T o1 → (o1 → o2) → T o2</div>

</font></div></blockquote><div><font class="Apple-style-span" face="&#39;courier new&#39;, monospace"><span class="Apple-style-span" style="font-family: arial; "><div><br></div><div>What else can I do to declare a Show instance for my datatype?</div>

<div><br></div><div>Thanks,</div><div>Anupam Jain</div><div><br></div></span></font></div>