Thanks very much for the clear explanation, as well as, of course, the work on GHC itself.
Am I reading correctly that forall is now a term-level keyword (i.e. can’t be used as an identifier) even without the new RequiredTypeArguments extension specified? Why? Was it too difficult to adjust the lexer to make forall keyword only in the presence of the language extension?
Am I reading correctly that
forallis now a term-level keyword (i.e. can’t be used as an identifier) even without the newRequiredTypeArgumentsextension specified?
That is correct.
Was it too difficult to adjust the lexer to make
forallkeyword only in the presence of the language extension?
This precedent had been set earlier, when forall was made an unconditional keyword in types (GHC Proposal #193). You can’t name a type variable forall even if ExplicitForAll is disabled.
That is, f :: a -> a is valid but f :: forall -> forall is not. The reason is that it improves error messages if you forget to enable ExplicitForAll.
Previously, this was only affecting type variables (but not term variables). RequiredTypeArguments is a step towards unifying type and term syntax. If forall is a keyword, it’s got to be a keyword everywhere. So we have two viable options
- Make
foralla keyword everywhere (types and terms) regardless of enabled extensions - Make
foralla keyword everywhere (types and terms) iffExplicitForAllis enabled
The committee has made the judgement call to go with option (1).