Skip to content
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

Allow duplicate fields #572

Open
MrQubo opened this issue Dec 16, 2023 · 2 comments
Open

Allow duplicate fields #572

MrQubo opened this issue Dec 16, 2023 · 2 comments

Comments

@MrQubo
Copy link

MrQubo commented Dec 16, 2023

Cabal supports duplicate fields in stanzas, hpack should as well.

@MrQubo
Copy link
Author

MrQubo commented Dec 16, 2023

The main problem to overcome is that YAML explicitly disallows duplicate fields. I can see two solutions.

  1. Stop using YAML and use YAML-like but with duplicate fields allowed. This can be implemented without writing own parser by using libyaml package.
  2. Use some valid YAML syntax for this feature, e.g.
    executables:
      example:
        - main: Main.hs
        - source-dirs: src
        - ghc-options: -O2
        - ghc-options: -Wall

The second solution feels a bit hacky, and I think the first one is better.

@MrQubo
Copy link
Author

MrQubo commented Dec 16, 2023

My use case is that with YAML's anchors it's not possible to merge lists (e.g. ghc-options). With duplicate fields I could do:

executables:
  example:
    main: Main.hs
    source-dirs: src
    ghc-options: *ghc-options-opt
    ghc-options: *ghc-options-warn

There are other solutions to my particular problem, but in my opinion, hpack should stick to be close to cabal whenever possible, as this results in less confusion for haskell developers, hence this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant