Version 1 (modified by Simon Marlow, 11 years ago) (diff)

The lexical rules for qualified identifiers lead to some unexpected consequences, and are tricky to implement, such that several existing compilers don't implement them properly.


  • M.where should be 3 lexemes (Hugs treats it as 1)
  • M... should be 2 lexemes (.. is a reserved symbol and can't be qualified, neigther GHC nor Hugs implements this)

The trickiness in implementation is due to the lookahead required. GHC deals with the first example with some special case code.

Fixing the lexical syntax is easy, we define

id -> small {small|large|digit|'}
varid -> id<reservedid>

qvarid -> [ modid . ] id

and similarly for qualified symbols.

An argument against doing this is that treating M.where as a qualified variable isn't very useful, since you can't define a variable called where. Perhaps it should be possible to use qualified identifiers in a definition, to make this consistent again?

In favour of making this change: most compilers don't get it right anyway, this is just a small change that makes it easier to implement Haskell.