[Haskell-cafe] Re: Re: type class question
jules at jellybean.co.uk
Fri Dec 7 11:23:55 EST 2007
Peter Padawitz wrote:
> Jules Bean wrote:
>> Peter Padawitz wrote:
>>> Functional dependencies don't work in my case. Actually, I don't see
>>> why they should.
>> Ah well, it's cruel to say that without explaining to us why!
> Cause I don't see why the instantiation conflicts pointed out by others
> would vanish then.
If it's really true that there is only one possible choice of b,c,d for
any particular a, then there are no conflicts, so you'd get no errors.
So the fundep would solve the problem.
>> class Java (a,b,c,d) where ....
> Yeah... but ghc accepts only type variables here, not arbitrary
> polymorphic types.
Indeed, but there is a workaround:
class Java all a b c d |
all -> a, all -> b, all -> c, all -> d, a,b,c,d -> all
instance Java (a,b,c,d) a b c d where...
but I'm not sure you need this.
More information about the Haskell-Cafe