-
Notifications
You must be signed in to change notification settings - Fork 18
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
GHC will recommend a module that is hidden #524
Comments
As you admit (by "best-effort"), this is hard in general. Indeed, it's possible that a library exposes a type with a class constraint such that the class cannot be imported at all. (This is likely poor design, but still possible.) As I think about the best way to do this, I think it's best done actually by an IDE, which would have a higher-level perspective than GHC. For example, an IDE can know what modules are imported elsewhere, what packages are in a cabal file, etc. Of course, the current infrastructure makes it very difficult for the IDE to edit the error message appropriately. We need structured error messages here, but it's hard to see how to do this well otherwise.. |
I guess I mean, GHC has two pieces of information up there that it could tie together. It could not that it can't deduce the class; then it could pre-empt the second error message by checking if the class it wants is actually public (surely that's doable?) and if not, it could give a hint in the first error:
? |
The Note @silky proposes is definitely doable, yes. Does it improve the status quo? |
for me i would argue it probably would; i was stuck in a loop of those two errors; had i seen both pieces of information at once, i might've solved it. ( note, in my actual case, i was a bit confounded by a third issue, namely that i had two versions of |
Consider:
Error is:
The problem is
Data.Hashable.Class
is hidden, so if I add:I get:
The actual fix here is to import
Data.Hashable (Hashable)
.Maybe we could do some kind of best-effort to find a publicly-exposed version of the constraint?
The text was updated successfully, but these errors were encountered: