GADTs: polymorphic type arguments

Ralf Hinze ralf at informatik.uni-bonn.de
Sat Nov 19 07:30:59 EST 2005


GHC currently forbids (G)ADTS with polymorphic type arguments:

> {-# OPTIONS -fglasgow-exts #-}
> data Com :: (* -> *) where
>   I :: Com (forall a . a -> a)

> eval :: Com t -> t
> eval I = id

This seems, however, rather benign. Unlike, for instance,
[forall a . a -> a], which is a list of polymorphic values.

Omitting the forall yields a working declaration:

> data Com :: (* -> *) where
>   I :: Com (a -> a)

Now, `I' has type forall a . Com (a -> a) rather than
Com (forall a . a -> a) and `eval' type checks ...

Cheers, Ralf



More information about the Glasgow-haskell-bugs mailing list