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

Is it possible to not suggest different imports for the same thing #531

Open
expipiplus1 opened this issue Oct 23, 2020 · 0 comments
Open
Labels

Comments

@expipiplus1
Copy link
Contributor

When I use mzero in my code I get 34 suggestions for importing the same thing!

...
3. import Control.Monad
4. import Control.Monad (MonadPlus(mzero))
5. import Control.Monad.Cont
6. import Control.Monad.Cont (MonadPlus(mzero))
7. import Control.Monad.Error
8. import Control.Monad.Error (MonadPlus(mzero))
9. import Control.Monad.Except
10. import Control.Monad.Except (MonadPlus(mzero))
11. import Control.Monad.Identity
12. import Control.Monad.Identity (MonadPlus(mzero))
13. import Control.Monad.List
14. import Control.Monad.List (MonadPlus(mzero))
15. import Control.Monad.RWS
16. import Control.Monad.RWS (MonadPlus(mzero))
17. import Control.Monad.RWS.Lazy
18. import Control.Monad.RWS.Lazy (MonadPlus(mzero))
19. import Control.Monad.RWS.Strict
20. import Control.Monad.RWS.Strict (MonadPlus(mzero))
21. import Control.Monad.Reader
22. import Control.Monad.Reader (MonadPlus(mzero))
23. import Control.Monad.State
24. import Control.Monad.State (MonadPlus(mzero))
25. import Control.Monad.State.Lazy
26. import Control.Monad.State.Lazy (MonadPlus(mzero))
27. import Control.Monad.State.Strict
28. import Control.Monad.State.Strict (MonadPlus(mzero))
29. import Control.Monad.Writer
30. import Control.Monad.Writer (MonadPlus(mzero))
31. import Control.Monad.Writer.Lazy
32. import Control.Monad.Writer.Lazy (MonadPlus(mzero))
33. import Control.Monad.Writer.Strict
34. import Control.Monad.Writer.Strict (MonadPlus(mzero))
35. import GHC.Base
36. import GHC.Base (MonadPlus(mzero))

(incidentally none of these are what I want (import Control.Monad (mzero)), but I think that's a separate issue perhaps)

Is it possible to detect that all of these are importing the same symbol and just suggest the canonical one*?

*Exactly what this is may in fact be quite difficult to determine, for instance when something is defined in Foo.Internal but the human programmer will always import from its reexport in Foo.

I wonder how hard it would be to examine Hackage to determine the provenance of imported symbols, and for HLS to only suggest the common imports. Just scraping import lines as an approximation shouldn't be the end of the world in terms of difficulty. Not sure how much data this would be to include, perhaps it's manageable if one leaves out the long tail of infrequently used imports.

Sorry for the rambling issue, hopefully it can stimulate some discussion.

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

No branches or pull requests

2 participants