4 Questions concerning the meaning of hiding in certain contexts:
6 1) Suppose we have the interface
14 Should this be an error (because T isn't an abstract type in the module)
15 or does it just mean the same thing as would
16 import A hiding (T (B,C))
18 import A hiding (T (..))
19 (in other words, hide all of T)
20 Will require the user to be precise and flag it as an error - otherwise
21 the user may not know that the type is not abstract, thinking that it is.
23 2) Clearly, we can't allow (assuming the interface above)
25 import A hiding (T (B))
27 since that means that a data type with a subset of the constructors is
28 exported - similarly for classes
30 3) Suppose an interface exports an abstract type H. Can H be referred
31 to as H (..), or is that an error? Let's require precision and call it
34 --------------- new design for renamer -------------------
36 Changes to abstract syntax
38 1) ClsSigs becomes Sigs
40 2) Instances need new syntax (bool) distinguishing between those which
41 come from an interface and those which come from a module.
43 The renamer is factored into four passes, as follows:
45 1) FLATTEN INTERFACES -
46 insert original names into interfaces. All of the decls imported
47 from the interfaces are collected and returned, in an otherwise
48 unchanged module. No interfaces exist after this pass.
50 2) Do consistency checks (equality). Return the module including the surviving declarations.
52 3) build the global name function, which will maintain two separate
55 4) assign names to the entire module, and do dependency analysis.
57 As the prelude environments will yield names, the first pass will replace
58 QuickStrings with constructors of the ProtoName type, defined as
60 data ProtoName = Unknown QuickString
61 -- note that this is the name local to the module
62 | Imported QuickString QuickString QuickString
65 The parser will initially make all QuickStrings Unknown.
67 Modules must now include signatures for value decls at top level.
69 The entire set of passes have the following types:
71 type PrelNameFuns = (GlobalNameFun, GlobalNameFun)
73 type GlobalNameFun = ProtoName -> Maybe Name
75 renameModule :: PrelNameFuns -> ProtoNameModule -> RenameMonad RenamedModule
77 renameModule1 :: PrelNameFuns -> ProtoNameModule -> RenameMonad ProtoNameModule
79 processModImports1 :: PrelNameFuns -> ProtoNameImportDecls
80 -> RenameMonad (ProtoNameFixityDecls, ProtoNameTyDecls,
81 ProtoNameClassDecls, ProtoNameInstDecls,
84 renameModule2 :: ProtoNameModule -> RenameMonad ProtoNameModule
86 renameModule3 :: PrelNameFuns -> ProtoNameModule -> GlobalNameFun
88 renameModule4 :: GlobalNameFun -> ProtoNameModule -> RenameMonad RenamedModule
90 renameModule :: PrelNameFuns -> ProtoNameModule -> RenameMonad RenamedModule
92 = (renameModule1 pnf mod) `thenRenameM` (\ mod_with_orig_interfaces ->
93 (renameModule2 mod_with_orig_interfaces)
94 `thenRenameM` (\ mod_minus_interfaces ->
95 (renameModule3 pnf mod_minus_interfaces)
96 `thenRenameM` (\ global_name_fun ->
97 (renameModule4 mod_minus_interfaces global_name_fun))))
99 Namespace confusion: According to the report (1.1), `An identifier must
100 not be used as the name of a type constructor and a class in the same
101 scope.' This is apparently the only constraint on the namespace, other
102 than those implied by the conventions for identifiers. So, what are the
105 1) variables and class operations, constructors
107 2) type constructors and classes (because of the statement above)