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

Extend functionality of 'expand src' to also delete missing module names #48

Open
Simre1 opened this issue Jul 14, 2022 · 2 comments
Open

Comments

@Simre1
Copy link

Simre1 commented Jul 14, 2022

Hi, i am mainly using cabal-fmt for its capabilities to add newly created modules to exposed-modules.

However, it does not work so well when I am moving modules around. cabal-fmt correctly adds the new name of the module to exposed-modules. The old name still persists and I have to delete it manually. It would be nice if cabal-fmt could also delete modules that no longer exist.

I am not sure about the specifics of the implementation. A solution would be to create an additional setting like -- cabal-fmt: expand src but for deleting module names; maybe -- cabal-fmt: clean src.

What do you think?

@Simre1 Simre1 changed the title Extend functionality of 'expand src' to also delete missing entries Extend functionality of 'expand src' to also delete missing module names Jul 14, 2022
@phadej
Copy link
Owner

phadej commented Sep 21, 2022

When formatting a stdin, we don't know the location of the .cabal file, so we cannot read contents of (correct) directories either.

The current adding behavior is consequence of that. If we succeed to read anything from filesystem, it's added, but nothing is ever removed.

I don't yet know whether allowing machinery to know whether there are filesystem reading functions is good thing to do.

@chris-martin
Copy link

chris-martin commented May 16, 2024

If I understand correctly, it seems like the behavior of cabal-fmt already varies based on the way it is used?

Current behavior:

  • When formatting stdin, no modules are added
  • When formatting a file path, modules may be added

Desired behavior:

  • When formatting stdin, no modules are added or removed
  • When formatting a file path, modules may be added or removed

I haven't looked at the code here yet, but as a user of this program it's difficult to understand in what sense "machinery to know whether there are filesystem reading functions" doesn't already exist, given that the program's output does depend upon whether it has been called with context sufficient to let it find module files.

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

No branches or pull requests

3 participants