[Haskell-cafe] Problem with existential quantification

David Menendez dave at zednenem.com
Thu Sep 25 16:44:15 EDT 2008


On Thu, Sep 25, 2008 at 1:15 PM, Eric <eeoam at ukfsn.org> 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

-- 
Dave Menendez <dave at zednenem.com>
<http://www.eyrie.org/~zednenem/>


More information about the Haskell-Cafe mailing list