-
Notifications
You must be signed in to change notification settings - Fork 642
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Idris export rules inflate namespaces, Haskell rules do no. Why ? #111
Comments
Hmm, I haven't really thought so much about import/export rules. It is to do with the way import works, which I know to be broken in some (easily fixable) ways. I'll have a think about how to do it properly, though I probably can't do it very quickly. The behaviour you're seeing is definitely wrong. |
Maybe it is not a problem if names which are defined in modules which But I think in this case the programmer needs some form of control. Edwin Brady notifications@github.com wrote:
|
The default is now that imported modules are not automatically reexported, and you need to say "import public A" if that's the behaviour you want (which is exactly the old behaviour). This might break a few things, but I think the new way is better, and what you were looking for. Sorry to take 2 years over this. At least it's evidence I get back to things eventually :). |
This is wonderful! |
Edwin Brady notifications@github.com wrote:
Thanks a lot Edwin, this is great news ! Best, Nicola
|
Fixes idris-lang#111 Previously, if a module B imports a module A, then a module C imports B, the public names in A would also be visible to C (i.e. B would automatically reexport everything from A). This seems to be a bad default. This patch changes the default behaviour so that the only names exported from a module are those defined in that module. If B imports A and wants to reexport everything in A, then A should be imported with the "public" modifier (i.e. "import public A"). Several changes have been made to the prelude, since several prelude modules were taking advantage of the old broken behaviour. This may cause lots of things to break. Sorry. The fix is typically just to import the module you should have imported anyway :).
The Haskell program
does not type check because, in |TestExport|, |A| is not visible. If one wants to use |MA.A| in |TestExport|, one has to import |MA|. This is good: if the names imported by a module were automatically injected in the namespaces of its clients, name clashes would hardly be avoidable. Maintaining and refactoring programs would be a nightmare: in order to find out the modules a program might depend upon, one would have to backwards reconstruct the whole import tree. In contrast, the Idris program
type checks. This suggests that the export rules of Idris might be fundamentally different from those of Haskell. Is this the case ? Why ?
The text was updated successfully, but these errors were encountered: