RE: infelicity in module imports
| Even with option 2, there is scope for confusion. "Import" | without "qualified", imports both qualified and unqualified | names, but adding the word "qualified" doesn't make any | difference to the position of qualified names, but instead | silently fails to import unqualified names. True | There is still a | strange asymmetry, too. Whereas adding "qualified" to "import | Modname ( a, b, c)" doesn't change which entities are | imported, just the ability to refer to them by unqualified | names, adding qualified" to "import Modname hiding ( a, b, | c)" has the effect of importing everything that was previously hidden. Not so. I hope the Report now unambiguously states that import M hiding (a,b,c) import qualified M hiding(a,b,c) imports exactly the same entities (namely all that M exports except a,b,c), only in the latter case only the qualified names are brought into scope. Can you suggest a way I could state it more clearly in the Report? | Personally, I think the right solution is to import entire | modules (the exported parts) qualified, and optionally to | allow unqualified reference to some or all names, with a syntax like | import modid [as modid] [unqualifying ( [all except] | impspec] | all) | | but it's probably too late for this. Dead right! Simon
"Simon Peyton-Jones" <simonpj@microsoft.com> writes:
I hope the Report now unambiguously states that
import M hiding (a,b,c) import qualified M hiding(a,b,c)
imports exactly the same entities (namely all that M exports except a,b,c), only in the latter case only the qualified names are brought into scope.
So using your example, in the first case we get d and M.d, but neither a nor M.a? And in the later case, we're supposed get M.d, but not M.a? Unless this has been changed in ghc > 5.00.1, ghc doesn't quite seem to implement this at the moment: import M hiding (a, b, c) imports d and all of M.a, M.b, ... (not just d and M.d); and import qualified M hiding (a, b, c) seems to do exactly the same thing as a straight import qualified M giving us M.a &c despite the hiding (a, b, c) clause. The behaviour I think you're describing seems by far the most useful thing do and the description in the report is now very clear, so this isn't an issue with anything you're proposing, just a observation that 'GHC implements it' isn't yet quite true. Cheers, Chris.
Simon Peyton-Jones wrote:
| There is still a | strange asymmetry, too. Whereas adding "qualified" to "import | Modname ( a, b, c)" doesn't change which entities are | imported, just the ability to refer to them by unqualified | names, adding qualified" to "import Modname hiding ( a, b, | c)" has the effect of importing everything that was previously hidden.
Not so. I hope the Report now unambiguously states that
import M hiding (a,b,c) import qualified M hiding(a,b,c)
imports exactly the same entities (namely all that M exports except a,b,c), only in the latter case only the qualified names are brought into scope.
Can you suggest a way I could state it more clearly in the Report?
I'm sure the version of the report I looked at yesterday still said that hiding clauses had no effect in qualified imports, which was the basis of my remark, but today's version clearly doesn't. I think the latest version is about as clear as we will get. --brian
participants (3)
-
Brian Boutel -
Chris Webb -
Simon Peyton-Jones