[Haskell-cafe] forall and a parse error

Andres Loeh loeh at iai.uni-bonn.de
Wed Nov 15 18:42:40 EST 2006

> Probably unrelated, but this thread is what triggered it for me.
> There is a minor bug in showing impredicative types without
> -fglasgow-exts: *hope I got that right*
> Prelude> let x = [] :: [forall a. a]
> <interactive>:1:23:
>     Warning: Accepting non-standard infix type constructor `.'
>              Use -fglasgow-exts to avoid this warning
> Prelude> :t x
> x :: [. (forall a) a]
>      ^^^^^^^^^^^^^^^^

This is a minor bug, but not the one I think you mean. Look at the
message. GHC says it's accepting the non-standard infix type
constructor called `.' ... So it's really interpreting `.' as an infix
type variable. It is also interpreting `forall' as a type variable, because
without -fglasgow-exts, `forall' is not a keyword, so it's a valid variable
name. So, renaming the `.' to `x' and `forall' to `f', your expression
is equivalent to

Prelude> let x = [] :: [x (f a) a]

and that is type-correct. This is also very close to what GHC prints as
the type, namely

[. (forall a) a]

So GHC decides to put `.' in prefix position, which is ok also for infix
type operators, but you have to put them in parentheses for GHC to re-accept
the type, so the bug is that GHC should really print

[(.) (forall a) a]

as type of `x'.


More information about the Haskell-Cafe mailing list