rikvdkleij / intellij-haskell

IntelliJ plugin for Haskell
https://rikvdkleij.github.io/intellij-haskell/
Apache License 2.0
1.31k stars 94 forks source link

feature request: add/remove/move a module in .cabal files when adding to project #580

Open aryairani opened 4 years ago

aryairani commented 4 years ago

In a multi-project build, it would be great to have .cabal files automatically updated when new modules are created or moved. Let me know if a more detailed description would be helpful!

rikvdkleij commented 4 years ago

Thanks for reporting!

Related to #383

Would be helpful if you can give more detailed description. I also wonder why not for single project build?

rikvdkleij commented 4 years ago

Btw, how is the responsiveness of the latest version of the plugin because in the past you had some issues?

aryairani commented 4 years ago

Would be helpful if you can give more detailed description.

When creating a module, it needs to be added to the .cabal file's exposed-modules: section before it will actually be part of the build. Similarly, when deleting a module, it needs to be removed from the exposed-modules: or other-modules: section. When moving or renaming module within a given package, the appropriate entry in the appropriate section needs to be renamed as well; and when moving/renaming a module between projects, it needs to be deleted from one .cabal package and added to another (which may be in the same .cabal file, or may be in separate files).

Along the same lines, but maybe technically a different feature: when moving or renaming a module, it would be nice if import references in the related files could be updated automatically.

I also wonder why not for single project build?

Hi, good point — yes, it would be helpful for a single project build too; I just don't have a single project build.

Btw, how is the responsiveness of the latest version of the plugin because in the past you had some issues?

^ Let me know if I should move this response to separate ticket!

I haven't been using the plugin a ton in the last few weeks, but I am starting again. I haven't encountered hangs yet, although I typically feel the need to run an instance of ghcid alongside IntelliJ IDEA, to get quicker feedback in terms of what's going on with the build. This should, in principle, actually make things slower because I'm now running an independent compilation in parallel, but currently I don't totally trust the build status as reported through IntelliJ IDEA.

For example, this doesn't tell me much (and in fact, I had a screenshot earlier with 4 simultaneous, overlapping builds, but accidentally overwrote it on the clipboard before I should share it): image

And then once the builds finish, I have a very out of date list of Haskell problems: image

The up-to-date list from ghcid looks like: image

I am currently running beta74, but I see that beta75 is available now!

rikvdkleij commented 4 years ago

Thanks for your extensive report!

I acknowledge the issue of builds and getting slow feedback when multiple components are involved. Especially a large project as Unison with multiple components can suffer this issue. The root case is because of one REPL per component. So if you change component A and component B depends on A and you switch to a file of B, then component A has to be rebuild and when it's finished then REPL B has to be restarted. So when that build takes some time and you keep switching and changing files then warnings/errors get outdated. But overlapping builds should not happen. I will take a look but the underlying problem is difficult to solve....

rikvdkleij commented 4 years ago

@aryairani Can you give beta76 a try?

In beta76 one REPL per stanza type instead of one REPL per component target. So no need to rebuild anymore when switching between lib targets of multiple projects.

aryairani commented 4 years ago

I will try it, thanks for the heads up!