[Haskell-cafe] Class constraints with "free" type variables and fundeps

Francesco Mazzoli f at mazzo.li
Sat Sep 29 02:36:12 CEST 2012

At Fri, 28 Sep 2012 17:19:36 -0700,
Alexander Solla wrote:
> Well, then what exactly is the problem?  Are you getting an error?

...well yes.  The error I get with the posted class declarations is

   Not in scope: type variable `b'

at the line with

   class Foo a b => Bar a where

Which I get because all the type vars in the LHS must be referenced on the RHS
(or so it seems).

Now, in my case the problem does not stop there, because I also want to
reference the tyvar on the LHS in a type signature of a method, since in that
case there is a fundep on b (`a -> b'), which makes `b' decidable if you have
`a' and `Foo a b'.

> You don't need to bring 'b' into scope.  You will already have real types in
> scope.
> instance Foo A B
> instance Bar A where foo A B = C

Again, I'm not sure what you mean here.

Francesco * Often in error, never in doubt

More information about the Haskell-Cafe mailing list