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

Draft: Format .cabal files with cabal-gild #4229

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

fendor
Copy link
Collaborator

@fendor fendor commented May 13, 2024

Compare with #4230

ghc-options:
-threaded
-- allow user RTS overrides
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

bad comment placement

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I made an issue: tfausak/cabal-gild#70

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's not a blocker, we can move these comments above the field and clarify

@fendor fendor force-pushed the enhance/format-with-cabal-gild branch from b3b4bd4 to dff31ba Compare May 13, 2024 09:52
directory,
extra,
filepath,
ghcide ==2.8.0.0,
Copy link
Collaborator

@jhrcek jhrcek May 13, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One more reason I prefer cabal-gild, is that it doesn't try to preserve version constraint indentation.
This leads to more diff friendly format (adding/removing dependency with longer than longest name, doesn't lead to indentation changes for other version constraints)
e.g.

short >=1.0
longer >= 2.0   < Adding longer dependency re-indents version constraint for shorter, which makes for longer diffs

@soulomoon
Copy link
Collaborator

can cabal-gild have , prefixing line breaking for items?

Copy link

@tfausak tfausak left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👋 I'm the author/maintainer of Gild. Let me know if I can do anything to help here!

copyright: Digital Asset and Ghcide contributors 2018-2020
synopsis: The core of an IDE
description: A library for building Haskell IDE's on top of the GHC API.
homepage: https://github.com/haskell/haskell-language-server/tree/master/ghcide#readme
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Which version of Gild was used here? As of 1.2.0.0 it shouldn't have re-formatted this line. (The URL should've stayed on its own line after homepage:.)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1.1.1.0 was used, will reformat with 1.2.0.0, thanks for the hint!

, unordered-containers >=0.2.10.0
, vector
Diff ^>=0.4.0,
Glob,
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I chose to make Gild sort things case sensitively, but I'm not set on it. See tfausak/cabal-gild#46.

unliftio >=0.2.6,
unliftio-core,
unordered-containers >=0.2.10.0,
vector,
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A lot of noise here from switching to trailing commas. I see that @soulomoon had a question about it too. Gild isn't (and hopefully won't be) configurable. I think trailing commas are generally preferable, especially when a final trailing comma is allowed (like it is in Cabal files for recent enough versions). It's a bit unfortunate in cases like this, but overall I think trailing commas are better.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm fan of this approach (non-configurability).
Similar approach is taken by elm-format, which became standard within elm community.
I like that most libraries you can get is formatted with it so there's very consistent feel to the whole ecosystem.
It eliminates a lot of pointless bickering on what format to choose.
One gets used to it pretty quickly.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanx for the reasonning, I am convinced that it is good.

description:
Backports for HIE files to GHC 8.8, along with a few other backports
of HIE file related fixes for ghcide.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This line was deleted because blank lines in the description field must be replaced by a lone period (foo\n.\nbar). You can see on Hackage that the description is all one paragraph: https://hackage.haskell.org/package/hie-compat-0.3.1.2

If you don't want to do that, you could upgrade to cabal-version: 3.0. You can see where Gild handles this here: https://github.com/tfausak/cabal-gild/blob/51425c05c67e6c335ba9024ced779669e3a4aca0/source/library/CabalGild/Unstable/Action/ReflowText.hs#L34

Here's the upstream Cabal PR for changing this behavior: haskell/cabal#5981

Compat.HieUtils

if (impl(ghc >= 9.2) && impl(ghc < 9.3))
hs-source-dirs: src-ghc92 src-reexport-ghc9
if (impl(ghc >= 9.2)&& impl(ghc < 9.3))
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm this formatting is no good. There should be a space before the &&. I made an issue for this: tfausak/cabal-gild#72

defaults
, warnings
, pedantic
-- plugins
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@tfausak here! This comment is (surprisingly?) preserved in situ.

@fendor fendor force-pushed the enhance/format-with-cabal-gild branch from dff31ba to ac4506d Compare May 15, 2024 07:34
@fendor fendor force-pushed the enhance/format-with-cabal-gild branch from ac4506d to 7bda10f Compare May 15, 2024 07:35
@fendor
Copy link
Collaborator Author

fendor commented May 15, 2024

Reformatted the .cabal files with cabal-gild-1.3.1.0 for accurate comparison.

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

Successfully merging this pull request may close these issues.

None yet

5 participants