Skip to content
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

Package name collisions #1043

Closed
rtfeldman opened this issue Sep 3, 2015 · 7 comments
Closed

Package name collisions #1043

rtfeldman opened this issue Sep 3, 2015 · 7 comments

Comments

@rtfeldman
Copy link
Member

We recently tried to import the Validate module from rtfeldman/elm-validate into a module that already imported an internal module named Validate. I was hopeful that this would work to disambiguate...

import Validate
import rtfeldman/elm-validate/Validate as ElmValidate

...but instead it was a syntax error.

In this case we can just rename our local module, but that wouldn't work if the conflict were between two third-party packages, both of which exposed a module with the same name.

Is there a plan for how to resolve that?

@Apanatshka
Copy link
Contributor

Perhaps your local application should have a separate namespace for all local modules?
I'm not saying it's a bad idea to have package name disambiguation, I haven't formed an opinion on that yet. But I do think the habit to put application-specific modules in an application-specific top-level module would be a good idea.

@rtfeldman
Copy link
Member Author

Not a bad idea, but as noted, there's already a known solution for the case where I have the ability to rename. I wanted to raise the issue because I believe currently if this happens at the package level, I have no recourse - which means some packages just fundamentally cannot be used together in the same module due to namespace conflicts.

That seems like a use case worth supporting in general, yeah?

(For what it's worth, it's not clear that this should be an elm-compiler issue. Perhaps a better solution would be to keep package concerns confined to elm-package.json and introduce some way to say "I depend on this package, but I want to rename this module that it exports to a different name to avoid conflicts.")

@TheSeamau5
Copy link

There's an old proposal of mine that was closed that spoke about this issue: #935

It was closed because this was a problem I had anticipated but no one had actually ever run into it, until now. Perhaps it would be valuable to re-open that issue in order to gather ideas on how best to support multiple packages with the same name.

@rtfeldman rtfeldman reopened this Sep 3, 2015
@rtfeldman
Copy link
Member Author

This is not blocking us, because one of the modules is local, so I'm not sure if this satisfies "people have run into this." I'll leave it open I suppose.

@evancz
Copy link
Member

evancz commented Sep 3, 2015

Fixing #826 will lay the groundwork for this. In 0.15.1 we could add syntax for this, but the infrastructure is not there to do the right thing.

In the latest master branch, we are pretty much done with #826 so this should just be a matter of figuring out syntax soon.

Can we close this issue and make a new one that:

  • describes your scenario briefly, linking here
  • gathers the syntax for this sort of feature from other languages along with links. I believe rust has this. I'd be curious about OCaml, SML, Haskell, Java, Python, Ruby, etc. etc.

Haskell seems to do okay putting a namespace in the module name. I get why that's dumb, but I don't yet get what's dumb about the alternative in practice and would like to be able to compare them fairly. I don't want opinions on this; I think it'd be way more productive to see examples, play through scenarios, and learn from people with experience with systems we have not used extensively.

@rtfeldman
Copy link
Member Author

Yep! Will do. Closing now; will make the other issue soon.

@connec
Copy link

connec commented Dec 17, 2016

As this is one of the first results when searching for this issue, and because multiple threads mention "waiting to see who runs into this", and because I can't find a more approriate follow-up issue:

I encountered this issue running through the Elm Guide. In particular I've been going through it 'manually', creating files in my editor from scratch and naming them based on the section. All was well through counter.elm, reverse.elm, and passwords.elm but on random.elm I encountered:

I found multiple modules named 'Random'.

Module 'Main' is trying to import it.

Modules with that name were found in the following locations:

    directory ././Random.elm
    package elm-lang/core

This occurs due to an import Random in the file.

(edit) To be clear I've currently changed the file name so I can keep on going, but I had expected there to be some way of importing a fully qualified package matching the dependency specification, such as import elm-lang/core/Random.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants