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

cabal format update command to update list of modules #5306

Open
gbaz opened this issue May 6, 2018 · 4 comments
Open

cabal format update command to update list of modules #5306

gbaz opened this issue May 6, 2018 · 4 comments

Comments

@gbaz
Copy link
Collaborator

gbaz commented May 6, 2018

The syntax is open to bikeshedding, but the idea is that cabal init auto-populates modules in a cabal file when it creates it. However, there's no way to auto-populate additional modules you may have since added.

It would be nice if we could add an update command that added to other-modules all modules in the source-dir not otherwise listed, so people didn't have to add them by hand as they added new modules to a project. We could even have a flag that controlled if they were added to exposed or other in the case of library stanzas.

Adding this as a subcommand of format makes sense imho because it uses the same round-tripping as format, and it also is blocked on public exposure by the same round-trip issues listed in : #2460

@23Skidoo
Copy link
Member

23Skidoo commented May 7, 2018

Like all similar features, I think this requires comment-preserving exactprint to be implemented first.

@gbaz
Copy link
Collaborator Author

gbaz commented May 7, 2018

Hrm. Ok, so in #2460 we have a full correct data roundtrip almost there except for one encoding issue. However, I guess that still leaves comments out. I confess I don't still know the full state of things. Are we fully on the parsec parsers now? Are there plans for a comment-preserving exactprint or any tickets describing the issue more fully. Or is there just a desire for this?

(i guess related prior art is ghc-exactprint and also https://dorchard.wordpress.com/2017/09/20/scrap-your-reprinter/)

@hvr
Copy link
Member

hvr commented May 16, 2018

Are we fully on the parsec parsers now?

For .cabal files, yes; since cabal 2.2

for cabal.project / cabal.config not yet

Are there plans for a comment-preserving exactprint

Yes, definitely -- the ability to roundtrip .cabal files is essential to achieve some goals for hackage revisions! But as usual, it's a priority-scheduling / scarce resource issue... in hindsight, this could have been a great GSOC project...

/cc @phadej

@fgaz
Copy link
Member

fgaz commented Mar 21, 2021

In the meantime, cabal-fmt can also update the module list. See here for how to use it: http://oleg.fi/gists/posts/2019-08-11-cabal-fmt.html#extra-expand-exposed-modules-and-other-modules

@ulysses4ever ulysses4ever changed the title cabal format update command cabal format update command to update list of modules Dec 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants