<br><br><div class="gmail_quote">On Fri, Sep 28, 2012 at 5:36 PM, Francesco Mazzoli <span dir="ltr"><<a href="mailto:f@mazzo.li" target="_blank">f@mazzo.li</a>></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>
> 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'<br>
<br>
at the line with<br>
<div class="im"><br>
class Foo a b => 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 -> b'), which makes `b' decidable if you have<br>
`a' and `Foo a b'.<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>
> You don't need to bring 'b' into scope. You will already have real types in<br>
> scope.<br>
><br>
> instance Foo A B<br>
> instance Bar A where foo A B = C<br>
<br>
</div>Again, I'm not sure what you mean here.</blockquote><div><br></div><div>I wouldn'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't memorized the Haskell 2010 report. We let the compiler tell us what'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 => Bar a where</div>
<div> foo :: a -> BarThing a -> 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 => Bar a where</div>
<div> type BarThing a :: *</div><div> foo :: a -> BarThing a -> 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>