GHC: Ticket #3491: Relax superclass restrictions
http://ghc.haskell.org/trac/ghc/ticket/3491
<p>
Doaitse points out that we currently reject
</p>
<pre class="wiki">class C a b | a -> b where
class C a b => D a where
</pre><p>
on the grounds that 'b' is not in scope in the second class decl. (Only type variables in the "head", namely (D a), can be mentioned in the superclass context.) My response to him was as follows.
</p>
<p>
The easiest way forward is to re-express your program using type functions. Then class C will have just a single type parameter (a), with the 'b' part being expressed by a type function. That would resolve the problem rather nicely.
</p>
<p>
Medium term, I think the Right Thing is to allow a class declaration
</p>
<pre class="wiki">class Q => C a b
</pre><p>
(where Q is a context) if and only iff the type
</p>
<pre class="wiki">forall ab. Q => C a b
</pre><p>
is unambiguous. What does "unambiguous" mean? As it happens, we are working on nailing that down right now. For example, here is a stupid but unambiguous declaration:
</p>
<pre class="wiki">type family F a
class (b ~ F a, Eq b) => C a
</pre><p>
I do not know of any non-stupid examples that would be rejected by the current rule, but there might be some.
I'll open a ticket because I'd like to get to this when we have the other pieces working.
</p>
en-usGHChttp://ghc.haskell.org/trac/ghc/chrome/site/ghc_logo.png
http://ghc.haskell.org/trac/ghc/ticket/3491
Trac 1.2.2.dev0simonmarFri, 06 Nov 2009 09:45:04 GMTstatus changed; resolution set
http://ghc.haskell.org/trac/ghc/ticket/3491#comment:1
http://ghc.haskell.org/trac/ghc/ticket/3491#comment:1
<ul>
<li><strong>status</strong>
changed from <em>new</em> to <em>closed</em>
</li>
<li><strong>resolution</strong>
set to <em>duplicate</em>
</li>
</ul>
<p>
ticket created twice: see <a class="new ticket" href="http://ghc.haskell.org/trac/ghc/ticket/3490" title="#3490: feature request: Relax superclass restrictions (new)">#3490</a>
</p>
Ticket