Skip to content

Hot-add dependencies #3288

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

Closed
lf- opened this issue Oct 14, 2022 · 3 comments
Closed

Hot-add dependencies #3288

lf- opened this issue Oct 14, 2022 · 3 comments
Labels

Comments

@lf-
Copy link
Contributor

lf- commented Oct 14, 2022

Is your enhancement request related to a problem? Please describe.

I often am working on a workspace that is rather slow to start up HLS in on account of having a Lot of Code. When I'm making a new package, I often forget to add dependencies as I go. Every time I add one, I have to restart HLS altogether.

Since I use nix, it's often the case that the dependencies are actually available in the ghc package database of the shell already, they just aren't declared as dependencies of this particular package.

For instance, if I import Extra in some file (n.b. ghc-pkg list only shows extra-1.7.11, not sure what's up there):

[not found] [E] Could not load module ‘Extra’
It is a member of the hidden package ‘extra-1.7.12’.
Perhaps you need to add ‘extra’ to the build-depends in your .cabal file.
It is a member of the hidden package ‘extra-1.7.10’.
Perhaps you need to add ‘extra’ to the build-depends in your .cabal file.
It is a member of the hidden package ‘extra-1.7.11’.
Perhaps you need to add ‘extra’ to the build-depends in your .cabal file.

Describe the solution you'd like

I would love the ability to hot-add stuff to the set of dependencies of my package. It would be totally fine by me if HLS was like "here I believe you added it, pinky swear", and did not necessarily implement actually editing the cabal file for you.

Describe alternatives you've considered

It could also work to see changes in the cabal file and live-add the packages to the session if they are already present and built. That would also solve my issue.

Additional context

@lf- lf- changed the title Simplify adding dependencies Hot-add dependencies Oct 14, 2022
@fendor
Copy link
Collaborator

fendor commented Oct 14, 2022

Kind of a duplicate of #155

In any way, slightly difficult to implement reliably. I think we are making some progress towards it with the hls-cabal-plugin.

It would be totally fine by me if HLS was like "here I believe you added it, pinky swear", and did not necessarily implement actually editing the cabal file for you.

While it might work in the nix case, in any other case, this seems like it is just going to make everything more complicated in other cases :)

@michaelpj
Copy link
Collaborator

I think the other issue covers editing the cabal file in this case. HLS would then reload the session.

I think actually hot-adding dependencies to the session is really hard and no worth it.

@michaelpj michaelpj closed this as not planned Won't fix, can't repro, duplicate, stale Nov 2, 2022
@georgefst
Copy link
Collaborator

I have often wanted something similar to this, though I suspected it might be impossible to implement robustly. A more modest proposal is to fix Cabal to make reloads quicker by recognising when a change to the .cabal file only requires a trivial modification of the flags passed to GHC. Or even more simply, avoiding the main expense, running the solver, when it isn't necessary. See haskell/cabal#9302 (reply in thread).

Anyway, these would involve changes entirely outside HLS.

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

4 participants