> While hacking around with MPCs, trying to define a variant of the
> Collection class, mutated to suit my own fiendish ends, I ran into
> this:
> 
> Intervals.hs:345:
>     Class type variable `e' does not appear in method signature
>         union2 :: s -> s -> s
> 
> What's the significance of this restriction?  (I presume this is caused
> by a requirement that all class vars appear in all methods.)  I don't
> recall it being mentioned in the proposal for MPCs, but I may have
> overlooked and/or forgotten it.  I don't suppose it ever really "bites"
> anyone, since one can always shove the appropriate constraint on the
> missing variable into the other methods, that do use it, but I don't
> instantly see why that's The Way to do it.

Not a dunce question.

I think the only reason for the original restriction in Haskell
(with one param) is this:

        class C a where
          op :: Int -> Int

Here op :: C a => Int -> Int, and hence *any* use of op is bound
to be ambiguous... which instance of C should we choose?  Hence
the rule. 

In the multi-paramter case things are less clear:

        class C a b where
           op :: a -> a

Here, op :: C a b => a -> a.  So suppose we use op on an Int argument.
Then we need to find an instance for (C Int b).  If there is an 
instance

        instance C Int b where
           ...

(and of course no overlapping instances) then we are home.
Is that your stituation here?  Maybe it is.  But more likely
you have

        instance C Int Int where
           ...

and now you're stuck, even if that's the only instance of (C Int t),
for any t.  Why stuck?  Because we ruled out "improvement" which
would instantiate b to Int in this case, on the grounds that 
its the only solution.

So, which is your situation?

Simon


Reply via email to