Skip to content

readGenericPackageDescription >>= writeGenericPackageDescription drops some fields #4719

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

Closed
duog opened this issue Aug 24, 2017 · 4 comments
Closed

Comments

@duog
Copy link
Contributor

duog commented Aug 24, 2017

Using ghc-8.2.1, with the bundled Cabal-2.0.0.2:

I would expect the following program to produce a new cabal file semantically the same as the one it is passed:

import Distribution.PackageDescription.PrettyPrint
import Distribution.PackageDescription.Parse
import Distribution.Verbosity
import System.Environment

main :: IO ()
main = do
  cabal_file : _ <- getArgs
  gpd <- readGenericPackageDescription normal cabal_file
  writeGenericPackageDescription (cabal_file ++ ".new") gpd

However, when run on doctest.cabal (from doctest-0.11.4), note that (at least) most of the fields from the executable doctest stanza are lost:
https://gist.github.com/duog/0576bf37434fb372bcafb9cbc053d3c1

@duog duog changed the title readGenericPackageDescription >>= writeGenericPackageDescription drops some flags and fields readGenericPackageDescription >>= writeGenericPackageDescription drops some fields Aug 24, 2017
@hvr
Copy link
Member

hvr commented Aug 24, 2017

Yeah, that's a known issue, writeGenericPackageDescription has been incomplete as long as I can rememeber. readGenericPackageDescription >>= writeGenericPackageDescription is basically what the hidden command cabal format does, and I think @phadej has been starting to pay attention (see e.g. #4697).

@23Skidoo
Copy link
Member

I think that this is basically a duplicate of #2607. Maybe we should open a single ticket for "cabal format doesn't work" with links to all relevant issues.

@duog
Copy link
Contributor Author

duog commented Aug 27, 2017

Should writeGenericPackageDescription be unexported until it is fixed? I think it's broken state should at least be mentioned in the haddocks.

@phadej
Copy link
Collaborator

phadej commented Aug 29, 2017

@duog, maybe for 2.0 branch: it cannot be hidden, as that will be breaking change. Documentation can always be improved.

The issue will be soon fixed in master.

phadej added a commit to phadej/cabal that referenced this issue Sep 1, 2017
- Parse custom-setup. Fixes haskell#4697 [ci skip]
- Rename PPP to FieldGrammar. Flatten D.PackageDescription namespace
- Add booleanFieldDef, flagFieldGrammar
- Correct FreeText parsec
- WIP: FieldGrammar BuildInfo and Library [ci skip]
- More newtypes [ci skip]
- Unknown and deprecated fields
- NoCommaFSep
- extra-libraries [ci skip]
- Parse 'else' [ci skip]
- WIP
- More BuildInfo opts [ci skip]
- ReadP parses 'location:\n' as location = Just "" [ci skip]
- Known fields [ci skip]
- monoidalField [ci skip]
- ^^^ operator
- RFC: Add elif [ci skip]
- Make FieldGrammar into a type class [ci skip]
- Parse sublibraries with FieldGrammar [ci skip]
- Use prettyFieldGrammar for library sections [ci skip]
- executableFieldGrammar [ci skip]
- ForeignLib grammar
- PackageDescription grammar [ci skip]
- Remove unused imports
- shake regression
- Update extra-source-files [ci skip]
- TestSuite & Benchmark grammars [ci skip]
- Change readp license-files setter [ci skip]
- Add hiddenField
- Add GPD parse . pretty roundtrip tests. Fixes haskell#4719
- Roundtrip hackage tests [ci skip]
- Roundtrip fixes [ci skip]
- More pretty-printing fixes
- More pp fixes [ci skip]
phadej added a commit to phadej/cabal that referenced this issue Sep 1, 2017
- Parse custom-setup. Fixes haskell#4697 [ci skip]
- Rename PPP to FieldGrammar. Flatten D.PackageDescription namespace
- Add booleanFieldDef, flagFieldGrammar
- Correct FreeText parsec
- WIP: FieldGrammar BuildInfo and Library [ci skip]
- More newtypes [ci skip]
- Unknown and deprecated fields
- NoCommaFSep
- extra-libraries [ci skip]
- Parse 'else' [ci skip]
- WIP
- More BuildInfo opts [ci skip]
- ReadP parses 'location:\n' as location = Just "" [ci skip]
- Known fields [ci skip]
- monoidalField [ci skip]
- ^^^ operator
- RFC: Add elif [ci skip]
- Make FieldGrammar into a type class [ci skip]
- Parse sublibraries with FieldGrammar [ci skip]
- Use prettyFieldGrammar for library sections [ci skip]
- executableFieldGrammar [ci skip]
- ForeignLib grammar
- PackageDescription grammar [ci skip]
- Remove unused imports
- shake regression
- Update extra-source-files [ci skip]
- TestSuite & Benchmark grammars [ci skip]
- Change readp license-files setter [ci skip]
- Add hiddenField
- Add GPD parse . pretty roundtrip tests. Fixes haskell#4719
- Roundtrip hackage tests [ci skip]
- Roundtrip fixes [ci skip]
- More pretty-printing fixes
- More pp fixes [ci skip]
phadej added a commit to phadej/cabal that referenced this issue Sep 2, 2017
- Parse custom-setup. Fixes haskell#4697 [ci skip]
- Rename PPP to FieldGrammar. Flatten D.PackageDescription namespace
- Add booleanFieldDef, flagFieldGrammar
- Correct FreeText parsec
- WIP: FieldGrammar BuildInfo and Library [ci skip]
- More newtypes [ci skip]
- Unknown and deprecated fields
- NoCommaFSep
- extra-libraries [ci skip]
- Parse 'else' [ci skip]
- WIP
- More BuildInfo opts [ci skip]
- ReadP parses 'location:\n' as location = Just "" [ci skip]
- Known fields [ci skip]
- monoidalField [ci skip]
- ^^^ operator
- RFC: Add elif [ci skip]
- Make FieldGrammar into a type class [ci skip]
- Parse sublibraries with FieldGrammar [ci skip]
- Use prettyFieldGrammar for library sections [ci skip]
- executableFieldGrammar [ci skip]
- ForeignLib grammar
- PackageDescription grammar [ci skip]
- Remove unused imports
- shake regression
- Update extra-source-files [ci skip]
- TestSuite & Benchmark grammars [ci skip]
- Change readp license-files setter [ci skip]
- Add hiddenField
- Add GPD parse . pretty roundtrip tests. Fixes haskell#4719
- Roundtrip hackage tests [ci skip]
- Roundtrip fixes [ci skip]
- More pretty-printing fixes
- More pp fixes [ci skip]
phadej added a commit to phadej/cabal that referenced this issue Sep 3, 2017
- Parse custom-setup. Fixes haskell#4697 [ci skip]
- Rename PPP to FieldGrammar. Flatten D.PackageDescription namespace
- Add booleanFieldDef, flagFieldGrammar
- Correct FreeText parsec
- WIP: FieldGrammar BuildInfo and Library [ci skip]
- More newtypes [ci skip]
- Unknown and deprecated fields
- NoCommaFSep
- extra-libraries [ci skip]
- Parse 'else' [ci skip]
- WIP
- More BuildInfo opts [ci skip]
- ReadP parses 'location:\n' as location = Just "" [ci skip]
- Known fields [ci skip]
- monoidalField [ci skip]
- ^^^ operator
- RFC: Add elif [ci skip]
- Make FieldGrammar into a type class [ci skip]
- Parse sublibraries with FieldGrammar [ci skip]
- Use prettyFieldGrammar for library sections [ci skip]
- executableFieldGrammar [ci skip]
- ForeignLib grammar
- PackageDescription grammar [ci skip]
- Remove unused imports
- shake regression
- Update extra-source-files [ci skip]
- TestSuite & Benchmark grammars [ci skip]
- Change readp license-files setter [ci skip]
- Add hiddenField
- Add GPD parse . pretty roundtrip tests. Fixes haskell#4719
- Roundtrip hackage tests [ci skip]
- Roundtrip fixes [ci skip]
- More pretty-printing fixes
- More pp fixes [ci skip]
phadej added a commit to phadej/cabal that referenced this issue Sep 3, 2017
- Parse custom-setup. Fixes haskell#4697 [ci skip]
- Rename PPP to FieldGrammar. Flatten D.PackageDescription namespace
- Add booleanFieldDef, flagFieldGrammar
- Correct FreeText parsec
- WIP: FieldGrammar BuildInfo and Library [ci skip]
- More newtypes [ci skip]
- Unknown and deprecated fields
- NoCommaFSep
- extra-libraries [ci skip]
- Parse 'else' [ci skip]
- WIP
- More BuildInfo opts [ci skip]
- ReadP parses 'location:\n' as location = Just "" [ci skip]
- Known fields [ci skip]
- monoidalField [ci skip]
- ^^^ operator
- RFC: Add elif [ci skip]
- Make FieldGrammar into a type class [ci skip]
- Parse sublibraries with FieldGrammar [ci skip]
- Use prettyFieldGrammar for library sections [ci skip]
- executableFieldGrammar [ci skip]
- ForeignLib grammar
- PackageDescription grammar [ci skip]
- Remove unused imports
- shake regression
- Update extra-source-files [ci skip]
- TestSuite & Benchmark grammars [ci skip]
- Change readp license-files setter [ci skip]
- Add hiddenField
- Add GPD parse . pretty roundtrip tests. Fixes haskell#4719
- Roundtrip hackage tests [ci skip]
- Roundtrip fixes [ci skip]
- More pretty-printing fixes
- More pp fixes [ci skip]
phadej added a commit to phadej/cabal that referenced this issue Sep 3, 2017
- Parse custom-setup. Fixes haskell#4697 [ci skip]
- Rename PPP to FieldGrammar. Flatten D.PackageDescription namespace
- Add booleanFieldDef, flagFieldGrammar
- Correct FreeText parsec
- WIP: FieldGrammar BuildInfo and Library [ci skip]
- More newtypes [ci skip]
- Unknown and deprecated fields
- NoCommaFSep
- extra-libraries [ci skip]
- Parse 'else' [ci skip]
- WIP
- More BuildInfo opts [ci skip]
- ReadP parses 'location:\n' as location = Just "" [ci skip]
- Known fields [ci skip]
- monoidalField [ci skip]
- ^^^ operator
- RFC: Add elif [ci skip]
- Make FieldGrammar into a type class [ci skip]
- Parse sublibraries with FieldGrammar [ci skip]
- Use prettyFieldGrammar for library sections [ci skip]
- executableFieldGrammar [ci skip]
- ForeignLib grammar
- PackageDescription grammar [ci skip]
- Remove unused imports
- shake regression
- Update extra-source-files [ci skip]
- TestSuite & Benchmark grammars [ci skip]
- Change readp license-files setter [ci skip]
- Add hiddenField
- Add GPD parse . pretty roundtrip tests. Fixes haskell#4719
- Roundtrip hackage tests [ci skip]
- Roundtrip fixes [ci skip]
- More pretty-printing fixes
- More pp fixes [ci skip]
phadej added a commit to phadej/cabal that referenced this issue Sep 3, 2017
- Parse custom-setup. Fixes haskell#4697
- Rename PPP to FieldGrammar. Flatten D.PackageDescription namespace
- Add booleanFieldDef, flagFieldGrammar
- Correct FreeText parsec
- WIP: FieldGrammar BuildInfo and Library
- More newtypes
- Unknown and deprecated fields
- NoCommaFSep
- extra-libraries
- Parse 'else'
- WIP
- More BuildInfo opts
- ReadP parses 'location:\n' as location = Just ""
- Known fields
- monoidalField
- ^^^ operator
- RFC: Add elif
- Make FieldGrammar into a type class
- Parse sublibraries with FieldGrammar
- Use prettyFieldGrammar for library sections
- executableFieldGrammar
- ForeignLib grammar
- PackageDescription grammar
- Remove unused imports
- shake regression
- Update extra-source-files
- TestSuite & Benchmark grammars
- Change readp license-files setter
- Add hiddenField
- Add GPD parse . pretty roundtrip tests. Fixes haskell#4719
- Roundtrip hackage tests
- Roundtrip fixes
- More pretty-printing fixes
- More pp fixes
phadej added a commit to phadej/cabal that referenced this issue Sep 3, 2017
- Parse custom-setup. Fixes haskell#4697
- Rename PPP to FieldGrammar. Flatten D.PackageDescription namespace
- Add booleanFieldDef, flagFieldGrammar
- Correct FreeText parsec
- WIP: FieldGrammar BuildInfo and Library
- More newtypes
- Unknown and deprecated fields
- NoCommaFSep
- extra-libraries
- Parse 'else'
- WIP
- More BuildInfo opts
- ReadP parses 'location:\n' as location = Just ""
- Known fields
- monoidalField
- ^^^ operator
- RFC: Add elif
- Make FieldGrammar into a type class
- Parse sublibraries with FieldGrammar
- Use prettyFieldGrammar for library sections
- executableFieldGrammar
- ForeignLib grammar
- PackageDescription grammar
- Remove unused imports
- shake regression
- Update extra-source-files
- TestSuite & Benchmark grammars
- Change readp license-files setter
- Add hiddenField
- Add GPD parse . pretty roundtrip tests. Fixes haskell#4719
- Roundtrip hackage tests
- Roundtrip fixes
- More pretty-printing fixes
- More pp fixes
phadej added a commit to phadej/cabal that referenced this issue Sep 4, 2017
- Parse custom-setup. Fixes haskell#4697
- Rename PPP to FieldGrammar. Flatten D.PackageDescription namespace
- Add booleanFieldDef, flagFieldGrammar
- Correct FreeText parsec
- WIP: FieldGrammar BuildInfo and Library
- More newtypes
- Unknown and deprecated fields
- NoCommaFSep
- extra-libraries
- Parse 'else'
- WIP
- More BuildInfo opts
- ReadP parses 'location:\n' as location = Just ""
- Known fields
- monoidalField
- ^^^ operator
- RFC: Add elif
- Make FieldGrammar into a type class
- Parse sublibraries with FieldGrammar
- Use prettyFieldGrammar for library sections
- executableFieldGrammar
- ForeignLib grammar
- PackageDescription grammar
- Remove unused imports
- shake regression
- Update extra-source-files
- TestSuite & Benchmark grammars
- Change readp license-files setter
- Add hiddenField
- Add GPD parse . pretty roundtrip tests. Fixes haskell#4719
- Roundtrip hackage tests
- Roundtrip fixes
- More pretty-printing fixes
- More pp fixes
phadej added a commit to phadej/cabal that referenced this issue Sep 4, 2017
This commit reworks how GenericPackageDescription is parsed from
`[Field Position]` and pretty-printed to `Doc`.

This also fixes few issues:
- Fix haskell#4697: `cabal format` doesn't output custom-setup stanza (nor
  foreign-lib stanzas)
- Fix haskell#4719: `parse . pretty . parse = parse`  for all Hackage cabal files.
    - `parser-hackage-tests roundtrip` is the test program.

The handling of `license-file` and `license-files` is changed.
Now they behave the same.
phadej added a commit to phadej/cabal that referenced this issue Sep 4, 2017
This commit reworks how GenericPackageDescription is parsed from
`[Field Position]` and pretty-printed to `Doc`.

This also fixes few issues:
- Fix haskell#4697: `cabal format` doesn't output custom-setup stanza (nor
  foreign-lib stanzas)
- Fix haskell#4719: `parse . pretty . parse = parse`  for all Hackage cabal files.
    - `parser-hackage-tests roundtrip` is the test program.

The handling of `license-file` and `license-files` is changed.
Now they behave the same.
phadej added a commit to phadej/cabal that referenced this issue Sep 5, 2017
This commit reworks how GenericPackageDescription is parsed from
`[Field Position]` and pretty-printed to `Doc`.

This also fixes few issues:
- Fix haskell#4697: `cabal format` doesn't output custom-setup stanza (nor
  foreign-lib stanzas)
- Fix haskell#4719: `parse . pretty . parse = parse`  for all Hackage cabal files.
    - `parser-hackage-tests roundtrip` is the test program.

The handling of `license-file` and `license-files` is changed.
Now they behave the same.
phadej added a commit to phadej/cabal that referenced this issue Sep 5, 2017
This commit reworks how GenericPackageDescription is parsed from
`[Field Position]` and pretty-printed to `Doc`.

This also fixes few issues:
- Fix haskell#4697: `cabal format` doesn't output custom-setup stanza (nor
  foreign-lib stanzas)
- Fix haskell#4719: `parse . pretty . parse = parse`  for all Hackage cabal files.
    - `parser-hackage-tests roundtrip` is the test program.

The handling of `license-file` and `license-files` is changed.
Now they behave the same.
@phadej phadej closed this as completed in c72fd0e Sep 20, 2017
alyssais added a commit to alyssais/nixpkgs that referenced this issue Nov 25, 2018
This reverts commit d13f7c5.

ghc802 is no longer in Nixpkgs as of
2f0de54.

The Cabal bug that ghc802 was a workaround for was fixed in Cabal 2.2,
though, so this shouldn't be necessary any more.

Upstream bugs:
NixOS/jailbreak-cabal#13
haskell/cabal#4719

Fixes NixOS#51042.
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