
Thanks! E. David Menendez wrote:
On Thu, Sep 25, 2008 at 1:15 PM, Eric
wrote: Dear all,
I've written a function with the following type:
build :: Bifunctor s => (forall b. (s a b -> b) -> b) -> Fix s a
When I try to compile I get the following error:
Illegal polymorphic or qualified type: forall b. (s a b -> b) -> b In the type signature for `build': build :: (Bifunctor s) => (forall b. (s a b -> b) -> b) -> Fix s a
What's happening?
That looks like it should work. I'm guessing you enabled ExistentialQuantification, but not Rank2Types or RankNTypes. The former allows you to use the forall keyword in data declarations, but you need one of the others to allow universal quantification in signatures, which is what build is using.
This could be better documented. The GHC manual lists all the extensions it supports, but it doesn't use the same terminology as the Extension codes (e.g. "arbitrary-rank polymorphism" instead of "RankNTypes"), and there is a hierarchy of extensions that appears to be entirely implicit. For example,
RankNTypes implies Rank2Types Rank2Types implies ExistentialQuantification Rank2Types implies PolymorphicComponents