<br><br><div class="gmail_quote">On Fri, Sep 28, 2012 at 5:36 PM, Francesco Mazzoli <span dir="ltr">&lt;<a href="mailto:f@mazzo.li" target="_blank">f@mazzo.li</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
At Fri, 28 Sep 2012 17:19:36 -0700,<br>
<div class="im">Alexander Solla wrote:<br>
&gt; Well, then what exactly is the problem?  Are you getting an error?<br>
<br>
</div>...well yes.  The error I get with the posted class declarations is<br>
<br>
   Not in scope: type variable `b&#39;<br>
<br>
at the line with<br>
<div class="im"><br>
   class Foo a b =&gt; Bar a where<br>
<br>
</div>Which I get because all the type vars in the LHS must be referenced on the RHS<br>
(or so it seems).<br></blockquote><div><br></div><div>Yes, indeed.</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
Now, in my case the problem does not stop there, because I also want to<br>
reference the tyvar on the LHS in a type signature of a method, since in that<br>
case there is a fundep on b (`a -&gt; b&#39;), which makes `b&#39; decidable if you have<br>
`a&#39; and `Foo a b&#39;.<br></blockquote><div><br></div><div>Only with respect to type inference.</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div class="im"><br>
&gt; You don&#39;t need to bring &#39;b&#39; into scope.  You will already have real types in<br>
&gt; scope.<br>
&gt;<br>
&gt; instance Foo A B<br>
&gt; instance Bar A where foo A B = C<br>
<br>
</div>Again, I&#39;m not sure what you mean here.</blockquote><div><br></div><div>I wouldn&#39;t have replied with that line of thought if you had just told us what the problem was in the first place.  I /was/ saying that you can use explicit type annotations to disambiguate instances.  </div>
<div><br></div><div>Most of us haven&#39;t memorized the Haskell 2010 report.  We let the compiler tell us what&#39;s wrong and either learn why, or how to fix it.  So post your errors.</div><div><br></div><div>By the way, it is rather rude to publicly post a private email...</div>
<div><br></div><div>Now, on to your real problem.</div><div><br></div><div>Use TypeFamilies instead:</div><div><br></div><div>class Foo a where</div><div>         type BarThing a :: *</div><div><br></div><div>class Foo a =&gt; Bar a where</div>
<div>         foo :: a -&gt; BarThing a -&gt; b</div><div><br></div><div>This is pretty pointless, since you can just refactor into the nearly equivalent:</div><div><br></div><div>class Foo a</div><div><br></div><div>class Foo a =&gt; Bar a where</div>
<div>        type BarThing a :: *</div><div>        foo :: a -&gt; BarThing a -&gt; c</div><div><br></div><div>It may or may not matter to which family the type synonym belongs.</div><div><br></div><div>What is the problem you are actually trying to solve?</div>
</div>