Hello,<br>I am making a little GATD:<br><br>&gt; {-# LANGUAGE GADTs#-}  <br> <br>&gt; data Obs a where<br>&gt;     Equal :: Obs a -&gt; Obs a -&gt; Obs Bool <br>&gt;     Plus :: (Num a) =&gt; Obs a -&gt; Obs a -&gt; Obs a<br>
(etc..)<br> <br>&gt; instance Show t =&gt; Show (Obs t) where<br>&gt;     show (Equal a b) = (show a) ++ &quot; Equal &quot; ++ (show b)<br>&gt;     show (Plus a b) = (show a) ++ &quot; Plus &quot; ++ (show b)<br> <br>&gt; instance Eq t =&gt; Eq (Obs t) where<br>
&gt;     a `Equal` b == c `Equal` d = (a == c) &amp;&amp; (b == d)<br>&gt;     a `Plus` b == c `Plus` d = (a == c) &amp;&amp; (b == d)<br><br><br>The Equal constructor causes me problems, while the Plus is fine:<br><br>test3.lhs:8:26:<br>
    Could not deduce (Show a) from the context (t ~ Bool)<br>      arising from a use of `show&#39; at test3.lhs:8:26-31<br>    Possible fix:<br>      add (Show a) to the context of the constructor `Equal&#39;<br>    In the first argument of `(++)&#39;, namely `(show a)&#39;<br>
    In the expression: (show a) ++ &quot; Equal &quot; ++ (show b)<br>    In the definition of `show&#39;:<br>        show (Equal a b) = (show a) ++ &quot; Equal &quot; ++ (show b)<br><br><br>I guess this is because GADT refines type with pattern matching.<br>
Since Equal return type is Obs Bool and not Obs a, it cannot bind the type variable a to belong to Show.<br><br>I don&#39;t see how to precise the type in the pattern match.<br><br>I have another problem:<br><br>test3.lhs:12:41:<br>
    Couldn&#39;t match expected type `a&#39; against inferred type `a1&#39;<br>      `a&#39; is a rigid type variable bound by<br>          the constructor `Equal&#39; at test3.lhs:12:8<br>      `a1&#39; is a rigid type variable bound by<br>
           the constructor `Equal&#39; at test3.lhs:12:23<br>      Expected type: Obs a<br>      Inferred type: Obs a1<br>    In the second argument of `(==)&#39;, namely `c&#39;<br>    In the first argument of `(&amp;&amp;)&#39;, namely `(a == c)&#39;<br>
<br>
<br>Cheers,<br>Corentin<br><br>