haskell / haskell/cabal

readPackageDescription >>= writeGenericPackageDescription adds strange duplicate stanza

Open
#2,343 2 comments 0 reactions 0 assignees View on GitHub
Cabal: other type: bug
Dominant language
Haskell
Stars
1.7k
Forks
750
Avg merge
4d 3h
Merged PRs (30d)
28

Description

I used the following test program

```
import Distribution.PackageDescription.Parse ( readPackageDescription )
import Distribution.PackageDescription.PrettyPrint ( writeGenericPackageDescription )
import Distribution.Verbosity

test :: FilePath -> IO ()
test cabalFile = readPackageDescription deafening cabalFile >>= writeGenericPackageDescription (cabalFile++"-new")
```

to read, parse, and write the [Cabal file of arithmoi](http://hackage.haskell.org/package/arithmoi-0.4.1.1/arithmoi.cabal), and I found that the output has a duplicated `build-depends` stanza I don't understand. The original file (cut down to the relevant part) says:

```
library
build-depends : base >= 4 && < 5, array >= 0.3 && < 0.6, ghc-prim,
integer-gmp < 1, containers >= 0.3 && < 0.6, random >= 1.0 && < 1.1,
mtl >= 2.0 && < 2.3
exposed-modules : ...
extensions : BangPatterns
ghc-options : -O2 -Wall
if flag(llvm)
ghc-options : -fllvm
ghc-prof-options : -O2 -auto
```

The re-generated expression, however, says:

```
library
build-depends:
base >=4 && <5,
array >=0.3 && <0.6,
ghc-prim -any,
integer-gmp <1,
containers >=0.3 && <0.6,
random >=1.0 && <1.1,
mtl >=2.0 && <2.3

if flag(llvm)
ghc-options: -fllvm
exposed-modules:
...
build-depends:
base >=4 && <5,
array >=0.3 && <0.6,
ghc-prim -any,
integer-gmp <1,
containers >=0.3 && <0.6,
random >=1.0 && <1.1,
mtl >=2.0 && <2.3
extensions: BangPatterns
other-modules:
...
```

Why is that dependency information duplicated in the generated output?

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.