hpack icon indicating copy to clipboard operation
hpack copied to clipboard

Preserve `tested-with` formatting from existing `.cabal` file

Open webdevred opened this issue 6 months ago • 2 comments

Problem:
hpack changes capitalization and spacing in the tested-with section, breaking Gild formatting. Related: #617

Expected behavior:
Maintain exact formatting, including capitalization, spacing, and commas.

Example:

-- Before (Gild-formatted)

tested-with:
  ghc ==9.4.7
  ghc ==9.6.6

-- After (hpack)

tested-with:
  GHC == 9.4.7,
  GHC == 9.6.6

webdevred avatar Oct 31 '25 19:10 webdevred

If commas are optional, then that is something we want to address. Again I will need to know:

  1. Starting from which cabal-version is the comma optional?

The other things are less clear cut, as they are not strictly better.

What is the original package.yaml that produces this output (minimal example).

sol avatar Nov 01 '25 10:11 sol

Hello, Sorry for the late update, there has been a lot happening during the latest weeks. I created a example repo for demonstrating how cabal gild formats files which were created by hpack.

Hpack example formatted by cabal gild: https://github.com/webdevred/hpack-example/commit/bf5f10b661618f08c24d4b1f33f7d94c5b77f2e4#diff-82b199226141b11408adea375e7906f2b46cb334c109d99525adcf6cc95712f3R114

Regarding this issue, I found this in the Cabal source code. https://github.com/haskell/cabal/blob/ae2ea9ecdb01e67d9f4801080be3d56cb4525422/Cabal-syntax/src/Distribution/Parsec.hs#L362

Best regards, webdevred

webdevred avatar Dec 20 '25 20:12 webdevred