From: simonpj Date: Thu, 14 Mar 2002 15:26:54 +0000 (+0000) Subject: [project @ 2002-03-14 15:26:53 by simonpj] X-Git-Tag: Approx_11550_changesets_converted~2267 X-Git-Url: http://git.megacz.com/?a=commitdiff_plain;h=057e3f0d571845f91178cb0e416566e063696425;p=ghc-hetmet.git [project @ 2002-03-14 15:26:53 by simonpj] Lots of stuff about external and internal names --- diff --git a/ghc/docs/comm/index.html b/ghc/docs/comm/index.html index 9ecc7a0..763c3a2 100644 --- a/ghc/docs/comm/index.html +++ b/ghc/docs/comm/index.html @@ -56,6 +56,7 @@
  • The Basics
  • Modules, ModuleNames and Packages +
  • The truth about names: Names and OccNamesd
  • The Real Story about Variables, Ids, TyVars, and the like
  • The Glorious Renamer diff --git a/ghc/docs/comm/the-beast/names.html b/ghc/docs/comm/the-beast/names.html new file mode 100644 index 0000000..1d7ce18 --- /dev/null +++ b/ghc/docs/comm/the-beast/names.html @@ -0,0 +1,142 @@ + + + + + The GHC Commentary - The truth about names: OccNames, and Names + + + +

    The GHC Commentary - The truth about names: OccNames, and Names

    +

    + + +Every entity (type constructor, class, identifier, type variable) has +a Name. The Name type is pervasive in GHC, +and is defined in basicTypes/Name.lhs. Here is what a Name looks like, +though it is private to the Name module. +

    +  data Name = Name {
    +		n_sort :: NameSort,	-- What sort of name it is
    +		n_occ  :: !OccName,	-- Its occurrence name
    +		n_uniq :: Unique,       -- Its identity
    +		n_loc  :: !SrcLoc	-- Definition site
    +	    }
    +
    + + + +

    The NameSort of a Name

    + +There are three flavours of Name: +
    +  data NameSort
    +    = External Module
    +    | Internal
    +    | System
    +
    + + + + +

    Occurrence names: OccName

    + +An OccName is more-or-less just a string, like "foo" or "Tree", +giving the (unqualified) name of an entity. + +Well, not quite just a string, because in Haskell a name like "C" could mean a type +constructor or data constructor, depending on context. So GHC defines a type +OccName (defined in basicTypes/OccName.lhs) that is a pair of +a FastString and a NameSpace indicating which name space the +name is drawn from: +
    +    data OccName = OccName NameSpace EncodedFS
    +
    +The EncodedFS is a synonym for FastString indicating that the +string is Z-encoded. (Details in OccName.lhs.) Z-encoding encodes +funny characters like '%' and '$' into alphabetic characters, like "zp" and "zd", +so that they can be used in object-file symbol tables without confusing linkers +and suchlike. + +

    +The name spaces are: +

    + + +Last modified: Tue Nov 13 14:11:35 EST 2001 + + + + + diff --git a/ghc/docs/comm/the-beast/renamer.html b/ghc/docs/comm/the-beast/renamer.html index 038a941..d48b34f 100644 --- a/ghc/docs/comm/the-beast/renamer.html +++ b/ghc/docs/comm/the-beast/renamer.html @@ -16,31 +16,12 @@ Roughly speaking, It has the type:
        HsModule RdrName -> HsModule Name
     
    -That is, it converts all the RdrNames to Names. +That is, it converts all the RdrNames to Names. -

    OccNames, RdrNames, and 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"). -Well, not quite just strings, because in Haskell a name like "C" could mean a type -constructor or data constructor, depending on context. So GHC defines a type -OccName (defined in basicTypes/OccName.lhs) that is a pair of -a FastString and a NameSpace indicating which name space the -name is drawn from: -
    -    data OccName = OccName NameSpace EncodedFS
    -
    -The EncodedFS is a synonym for FastString indicating that the -string is Z-encoded. (Details in OccName.lhs.) -

    -The name spaces are: -

    -So a RdrName is defined thus: +like "f") or a pair of strings (for a qualified name like "M.f"):
         data RdrName = RdrName Qual OccName
         
    @@ -54,35 +35,11 @@ So a RdrName is defined thus:
     	      | 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. -

    -On the other hand, a Name: -

    -The original name of an entity (type constructor, class, function etc) is -the (module,name) pair describing where the thing was originally defined. So for example, -if we have -
    -  module M where
    -    f = e1
    -    g = e2
    -
    -  module A where
    -    import qualified M as Q
    -    import M
    -    a = Q.f + g
    -
    -then the RdrNames for "a", "Q.f" and "g" get replaced by the Names -"A.a", "M.f", and "M.g" respectively. -

    -Names come in two flavours: Local and Global. The Global kind contain -both a Module and an OccName -Not all Names are qualifed. Local (e.g. lambda-bound) names are given Local Names

    Rebindable syntax

    diff --git a/ghc/docs/comm/the-beast/vars.html b/ghc/docs/comm/the-beast/vars.html index d7d700b..c2c1ce0 100644 --- a/ghc/docs/comm/the-beast/vars.html +++ b/ghc/docs/comm/the-beast/vars.html @@ -26,10 +26,12 @@ represents variables, both term variables and type variables: