-
Notifications
You must be signed in to change notification settings - Fork 657
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
Error trying to import module not in the exposed-modules list of a package could be improved. #2253
Comments
Thanks for reporting this! To set expectations:
Finally, please be patient with the core team. They are trying their best with limited resources. |
@houseofmercy-github A problem here is that there is no relation between a module's name and the package it comes from. While it is somewhat obvious (to a human) that And it might not actually be obvious. Maybe you also depend on The only thing that connects the two is the package's Technically, it could find that information from looking at the different files in the |
@jfmengels Thank you for the explaination. If there is no easy way for the compiler to look for non-exposed modules of an imported package then a precise suggestion might not be worth the performance cost. Perhaps the error message in this case could simply include a generic hint that importing a module not listed in the package's If the operations involved are more expensive then perhaps a separate "lint" utility that could make more assumptions about the user's code would be a better place for it. Are you aware of anything like that? I'm new to Elm but would be happy to try and make a PR that could do that. |
If you look for a linter, you should probably check out I also think that this is the kind of issue that once you've encountered once, you'll know about it. Beginners won't think about using a separate tool (they probably won't even discover it), so I think that this should either be addressed by the compiler or not addressed at all
I agree that the compiler could give a slightly better answer, though I'm at a loss as to what details to add because there needs to be a trade-off between a short helpful explanation and a long detailed one. I don't think we want to confuse beginners with all the details I mentioned, especially since the most likely case for this error to happen is that the user forgot to create a file or renamed a file without changing the import (which the current error doesn't address super well actually). In your particular use-case, I think you got confused because you looked at the source code, whereas you should have ideally looked at the package's documentation (I mean in an ideal world, not saying you did anything bad at all, on the contrary). If that didn't give you the information you wanted, then I'd report that there and maybe open a PR to improve the documentation there. That sounds like an easier way to start contributing :) (and I know that Dillon welcomes the help ;) ) |
Thank you. I will take a look at elm-review. This is definitely one of those things I'll know to watch out for in the future. I probably should have started with something less ambitious then helping custom html handlers in elm-markdown report better errors but I was so impressed by it otherwise that I felt I had to give it try. I think some form of your description would make sense in the elm guide since it talks quite a bit about modules but doesn't mention the |
Quick Summary:
For example https://ellie-app.com/hcbgFYzMTQYa1 reports the error
The real problem seems to be that dillonkearns/elm-markdown does not include
Markdown.HtmlRenderer
in itsexposed-modules
so other modules may not import it.Suggestion
It would be more informative if the error were to explicitly mention this. E.g.
The Modules section of the elm guide could also mention the https://github.com/elm/compiler/blob/master/docs/elm.json/package.md#exposed-modules setting explicitly.
SSCCE
https://ellie-app.com/hcbgFYzMTQYa1
which simply adds
to https://ellie-app.com/d7R3b9FsHfCa1
Additional Details
What I was trying to do at the time:
https://old.reddit.com/r/elm/comments/tw36nv/easy_questions_beginners_thread_week_of_20220404/i3x2lrj
What I discovered a few days later
https://old.reddit.com/r/elm/comments/tw36nv/easy_questions_beginners_thread_week_of_20220404/i4g5msp
The text was updated successfully, but these errors were encountered: