The GHC Commentary - The Glorious Renamer

(This section is, like most of the Commentary, rather incomplete.)

The renamer sits between the parser and the typechecker. Roughly speaking, It has the type:

   HsModule RdrName -> HsModule Name
That is, it converts all the RdrNames to Names.

RdrNames

A RdrNames is pretty much just a string (for an unqualified name like "f") or a pair of strings (for a qualified name like "M.f"):
    data RdrName = RdrName Qual OccName
    
    data Qual = Unqual
    
	      | Qual ModuleName     -- A qualified name written by the user in source code
				    -- The module isn't necessarily the module where
				    -- the thing is defined; just the one from which it
				    -- is imported
    
	      | Orig ModuleName	    -- This is an *original* name; the module is the place
				    -- where the thing was defined
The OccName type is described in "The truth about names".

The OrigName variant is used internally; it allows GHC to speak of RdrNames that refer to the original name of the thing.

Rebindable syntax

In Haskell when one writes "3" one gets "fromInteger 3", where "fromInteger" comes from the Prelude (regardless of whether the Prelude is in scope). If you want to completely redefine numbers, that becomes inconvenient. So GHC lets you say "-fno-implicit-prelude"; in that case, the "fromInteger" comes from whatever is in scope. (This is documented in the User Guide.)

This feature is implemented as follows (I always forget).

Last modified: Tue Nov 13 14:11:35 EST 2001