Puzzled by error with forall quantifier.

Can anyone explain the following error message from Hug98 (with extensions enabled)? I have
class Space t class Space t => HasY v t where assignY :: v -> t -> t getY :: t -> v varY :: forall w . Space w => v -> (t->t) -> (w->w)
I get an error on the last definition "quantifier does not mention type variable v" (and if I quantify v, then it complains that t is not quantified). The idea I'm trying to express is that for any instance of HasY v t there should be a function varY with type v -> (t->t) -> (w->w) for some type w of class Space. Any help much appreciated. Is there any kind of tutorial introduction to "forall" out there? Cheers, Theo Norvell

hello, just skip the forall. "free" type variables are implicitly forall-quantified. the forall keyword is used for functions that need to take polymorphic functions as arguments, but that's advanced stuff. so in short, this should work:
class Space t class Space t => HasY v t where assignY :: v -> t -> t getY :: t -> v varY :: Space w => v -> (t->t) -> (w->w)
the next problem you are likely to run into is ambiguities, and you might want to take a look at functional dependencies. hope this helps iavor Theodore S. Norvell wrote:
Can anyone explain the following error message from Hug98 (with extensions enabled)?
I have
class Space t class Space t => HasY v t where assignY :: v -> t -> t getY :: t -> v varY :: forall w . Space w => v -> (t->t) -> (w->w)
I get an error on the last definition "quantifier does not mention type variable v" (and if I quantify v, then it complains that t is not quantified).
The idea I'm trying to express is that for any instance of HasY v t there should be a function varY with type v -> (t->t) -> (w->w) for some type w of class Space.
Any help much appreciated.
Is there any kind of tutorial introduction to "forall" out there?
Cheers, Theo Norvell
_______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
-- ================================================== | Iavor S. Diatchki, Ph.D. student | | Department of Computer Science and Engineering | | School of OGI at OHSU | | http://www.cse.ogi.edu/~diatchki | ==================================================

Iavor S. Diatchki wrote:
just skip the forall. "free" type variables are implicitly forall-quantified.
Of course! Thanks. The problem is that I actually wanted "exists". However as the type that exists is functionally dependent on other the parameters to the class I think I can deal with it using functional dependencies, as you suggest. Sorry for the elementary question. Cheers, Theo Norvell
participants (2)
-
Iavor S. Diatchki
-
Theodore S. Norvell