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 init generates badly formatted file #5555

Open
osa1 opened this issue Aug 31, 2018 · 8 comments
Open

cabal init generates badly formatted file #5555

osa1 opened this issue Aug 31, 2018 · 8 comments

Comments

@osa1
Copy link

osa1 commented Aug 31, 2018

(tried with cabal installed from master branch)

cabal init generates .cabal file with very long lines for fields like other-extensions, exposed-modules and build-depends. Fixing this by hand is tedious. Cabal format helps, but that's hard to discover (#2460). Ideally I think cabal should format the file before automatically.

@23Skidoo
Copy link
Member

/cc @byorgey

@chshersh
Copy link
Member

chshersh commented Sep 1, 2018

I personally prefer formatting of cabal init command so I wouldn't call it a badly formatted file. And in all my projects I format .cabal files in the style of cabal init (with alignment). I never heard of cabal format command before but after I tried this command now I see that there's no benefit in the cabal format formatting for me and I don't like the style of cabal format. So I'm voting for leaving cabal init formatting as it is.

@osa1
Copy link
Author

osa1 commented Sep 1, 2018

Just to clarify, this is what cabal init generates:

build-depends:       base >=4.11 && <4.12, QuickCheck >=2.11 && <2.12, hashable >=1.2 && <1.3, containers >=0.5 && <0.6, fingertree >=0.1 && <0.2, stm >=2.4 && <2.5, random >=1.1 && <1.2, text >=1.2 && <1.3, bytestring >=0.10 && <0.11, async >=2.2 && <2.3, transformers >=0.5 && <0.6, directory >=1.3 && <1.4, filepath >=1.4 && <1.5, free >=5.1 && <5.2

This is unusable without formatting first. Compare with cabal format output:

    build-depends:
        base >=4.11 && <4.12,
        QuickCheck >=2.11 && <2.12,
        hashable >=1.2 && <1.3,
        containers >=0.5 && <0.6,
        fingertree >=0.1 && <0.2,
        stm >=2.4 && <2.5,
        random >=1.1 && <1.2,
        text >=1.2 && <1.3,
        bytestring >=0.10 && <0.11,
        async >=2.2 && <2.3,
        transformers >=0.5 && <0.6,
        directory >=1.3 && <1.4,
        filepath >=1.4 && <1.5,
        free >=5.1 && <5.2

@chshersh
Copy link
Member

chshersh commented Sep 2, 2018

@osa1 My bad, I haven't understand your ticket good enough. Yeah, I don't like long lists with dependencies as well.

@byorgey
Copy link
Member

byorgey commented Feb 3, 2019

The format command simply calls readGenericPackageDescription followed by writeGenericPackageDescription. I don't think those existed when I first wrote cabal init. Right now, cabal init does its own pretty-printing; I think the correct solution would be to instead create a GenericPackageDescription and then call writeGenericPackageDescription, so it uses the same code path as cabal format.

@byorgey
Copy link
Member

byorgey commented Feb 3, 2019

Hmm, actually, how do read/writeGenericPackageDescription deal with comments? As far as I can see the answer seems to be "they don't", which seems problematic from the point of view of cabal init...

@23Skidoo
Copy link
Member

23Skidoo commented Feb 4, 2019

Correct, we don't have exactprint yet.

@phadej
Copy link
Collaborator

phadej commented Feb 4, 2019

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

Successfully merging a pull request may close this issue.

7 participants