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

Coming to a decision regarding the short to medium-term future of cabal format #8797

Closed
Kleidukos opened this issue Feb 22, 2023 · 4 comments

Comments

@Kleidukos
Copy link
Member

#5734 is still relevant in cabal-install 3.9.0.0 and this is a rather shameful footgun. There are today alternatives to it, like @phadej/cabal-fmt, which performs much better.

In parallel, we do not even show format in the cabal --help message.

I would like us to take a decision regarding what we make of the format option.

@phadej Although I understand that the "goal of [this] project is to iterate independently of cabal-install"¹, would you say that it has reached suitable maturity for integration? I use the auto-expander syntax these days and I'm satisfied of how it works.

Personally I'd like see cabal-fmt as a new code path for cabal format. This can be advertised as being experimental, but in the end a clear improvement for the users.

@Kleidukos Kleidukos changed the title Come to a decision regarding the short to medium-term future of cabal format Coming to a decision regarding the short to medium-term future of cabal format Feb 22, 2023
@Kleidukos
Copy link
Member Author

After discussion with the other members of the core team, it has been established that cabal-fmt is unmergeable, with its own idiosyncrasies that are too hard to properly manage.

@Kleidukos
Copy link
Member Author

Upon seeing the command used by an innocent victim, I think we have to change a couple of things about its presentation.

From off-site:

hahaha what the actual fuck, TIL that cabal format expands out common stanzas
and also whatever "standard style" the command help says it uses, it's objectively bad

Clearly we violate a number of principles with this command, including the principle of least surprise.
I'll open a PR to better manage the expectations of the users and remove references to non-existent standards.

@fendor
Copy link
Collaborator

fendor commented Feb 26, 2023

It seems the "standard style" is more like a pretty-printed normalised form of a cabal file.
It even eats comments in the sources (which is not surprising, since we don't have an exactprinter or anything).

In my opinion, cabal format should be re-branded as not being a formatter but an internal tool for uniformly presenting cabal files, maybe for tooling, or something like that. Not for human developers trying to prettify their .cabal or cabal.project files.

However, I am uncertain if we should have a formatting tool shipping with .cabal at all. I don't think other tools do that (although admittedly, most other langs I know have no custom formats for package specification), and it'd be much better to spend time on a potential exactprinter, such as #7626. This would foster friendly competition between multiple formatting libs with different design goals (minimal diffs vs vertical alignment, etc...). Similar to the haskell formatters that are out there already.
Additionally, exactprinter would be great for HLS's cabal plugin ;)

@gbaz
Copy link
Collaborator

gbaz commented Feb 27, 2023

The format command is not listed in cabal --help nor in the cabal readthedocs precisely because it isn't in great shape given the lack of an exactprint or the like. The one thing that could be done simply is changing the cabal format --help message itself to indicate it is an experimental or partially implemented command. But outside of that, it isn't advertised anywhere as something for people to use.

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

4 participants