The problem is that you have an existential `t` there, and two values of the type Foo might not have the same `t` inside them.<div><br></div><div>What do you want to happen if someone writes Foo True == Foo &quot;yep&quot;?</div>
<div><br></div><div>The only real solution here is to parametrize your Foo type by the t that lives within it, so you can ensure the inner types are the same. You could also do some (in my opinion) fairly nasty stuff with Dynamic or Typeable, adding a constraint to the Eq and attempting to cast at runtime (returning False if the cast returns Nothing).</div>
<div><br></div><div>Hope this helps!<br><br><div class="gmail_quote">On Mon, Aug 23, 2010 at 12:36 AM, Markus Barenhoff <span dir="ltr">&lt;<a href="mailto:alios@alios.org">alios@alios.org</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
Hello,<br>
playing with GADTs I ran into a problem with rigid type variables<br>
which is ilustrated by the following example. I think it should be<br>
pretty clear what I&#39;am trying to express... Any suggestions?<br>
<br>
---- snip ----<br>
{-# LANGUAGE GADTs #-}<br>
<br>
data Foo where<br>
  Foo :: (Eq t) =&gt; t -&gt; Foo<br>
<br>
instance Eq Foo where<br>
  (Foo a) == (Foo b) = a == b<br>
<br>
{-<br>
Scratch.hs:7:28:<br>
    Couldn&#39;t match expected type `t&#39; against inferred type `t1&#39;<br>
      `t&#39; is a rigid type variable bound by<br>
          the constructor `Foo&#39; at /home/alios/src/lab/Scratch.hs:7:3<br>
      `t1&#39; is a rigid type variable bound by<br>
           the constructor `Foo&#39; at /home/alios/src/lab/Scratch.hs:7:14<br>
    In the second argument of `(==)&#39;, namely `b&#39;<br>
    In the expression: a == b<br>
    In the definition of `==&#39;: (Foo a) == (Foo b) = a == b<br>
Failed, modules loaded: none.<br>
-}<br>
---- snip ----<br>
<br>
thnx<br>
Markus<br>
_______________________________________________<br>
Haskell-Cafe mailing list<br>
<a href="mailto:Haskell-Cafe@haskell.org">Haskell-Cafe@haskell.org</a><br>
<a href="http://www.haskell.org/mailman/listinfo/haskell-cafe" target="_blank">http://www.haskell.org/mailman/listinfo/haskell-cafe</a><br>
</blockquote></div><br></div>