Skip to content

readGenericPackageDescription >>= writeGenericPackageDescription drops some fields #4719

Closed

Description

@duog

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

Activity

  1. changed the title [-]readGenericPackageDescription >>= writeGenericPackageDescription drops some flags and fields[/-] [+]readGenericPackageDescription >>= writeGenericPackageDescription drops some fields[/+] on Aug 24, 2017
  2. hvr commented on Aug 24, 2017

    @hvr
    Member

    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).

  3. 23Skidoo commented on Aug 24, 2017

    @23Skidoo
    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.

  4. duog commented on Aug 27, 2017

    @duog
    ContributorAuthor

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

  5. added a commit that references this issue on Aug 29, 2017
    1a2613d
  6. phadej commented on Aug 29, 2017

    @phadej
    Collaborator

    @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.

  7. added 13 commits that reference this issue on Sep 1, 2017
    63beb51
    51493a4
    4cf6ff7
    f393094
    f8a46a2
    13c4daa
    f6a842f
    ab64fca
    b65125e
    1032b2a
    690a725
    4d6057b
    80c19b4
  8. added a commit that references this issue on Sep 20, 2017
    c72fd0e
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions