-
Notifications
You must be signed in to change notification settings - Fork 701
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
Use PrettyField to format cabal file in cabal init
#6718
Conversation
efbc3c7
to
6213832
Compare
6213832
to
de3eb91
Compare
cabal init
cabal init
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good start!
de3eb91
to
03faa1a
Compare
About Unspecified/any version range formatting, I think we can change how
will run roundtrip tests on Hackage data, so if it passes, I'm confident it's ok. I don't like extra EDIT: we don't need to worry about other usages of |
03faa1a
to
346e3e5
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Alright, think I addressed all your comments, lmk if I missed anything!
7.10.3 failure is legit |
Huh, interesting. The failure is on line 278 in the Also, when trying to build with ghc-7.10.3 locally Build log``` Failed to build cryptohash-sha256-0.11.101.0. Build log ( /home/mrenaud/.cabal/logs/ghc-7.10.3/cryptohash-sha256-0.11.101.0-541559c14cc76365a19f26bf3fd7c60613e1870c1ce0f5cd3363cf2a9b76d027.log ): Configuring library for cryptohash-sha256-0.11.101.0.. Warning: Packages using 'cabal-version: >= 1.10' must specify the 'default-language' field for each component (e.g. Haskell98 or Haskell2010). If a component uses different languages in different modules then list the other ones in the 'other-languages' field. Preprocessing library for cryptohash-sha256-0.11.101.0.. Building library for cryptohash-sha256-0.11.101.0.. [1 of 2] Compiling Crypto.Hash.SHA256.FFI ( src/Crypto/Hash/SHA256/FFI.hs, dist/build/Crypto/Hash/SHA256/FFI.o ) /usr/bin/ld: -r and -pie may not be used together collect2: error: ld returned 1 exit status cabal: Failed to build cryptohash-sha256-0.11.101.0 (which is required by test:unit-tests from cabal-install-3.3.0.0, test:solver-quickcheck from cabal-install-3.3.0.0 and others). See the build log above for details. ``` |
Appears to be a poor interaction with OverloadedStrings in ghc 7.10.3.
Looks like a poor interaction between OverloadedStrings and ghc 7.10.3. |
I added changelog and merged (squashed) as 10051c3 |
This PR replaces the hard-rolled cabal file formatting with PrettyField.
Notable differences:
This resolves #5555.
Open Questions
Unspecified/any version range formatting
It appears not to be possible to pretty-print a dependency of the form:
<package-name>
with no version constraints, the only matching constructor forVersionRange
isAnyVersion
which is printed as<package-name> -any
. This "unspecified" version range is needed to express a dependency from the package executable to the library within the same package (as is created in--libandexe
).Looking for input on a solution here, we could introduce a new
UnspecifiedVersion
constructor such that:How to represent standalone comments in
PrettyField
Currently (see below) I've created a new constructor in
PrettyField
for a "commented out" field that can also have comments. Should this be generalized to justPrettyComment
? Thoughts on implementation here?Implementation Notes
In order to re-use the pretty-printing logic I needed to expose the specific list format functions from
FieldGrammar.hs
. These functions mostly wrap list fields in newtypes so the pretty printer knows how to lay them out.The one thing that was not easy to express with the existing
PrettyField
construct was commented out fields that also had comments associated with them. To address this I added a new constructor to thePrettyField
type, namelyPrettyFieldCommentedOut
, this is pretty specific and should probably just be renamed toPrettyComment
or similar, lmk what you think about this.Testing
Please include the following checklist in your PR:
changelog.d
directory).Please also shortly describe how you tested your change. Bonus points for added tests!