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

Support for common stanzas #569

Open
ramirez7 opened this issue Oct 2, 2023 · 2 comments
Open

Support for common stanzas #569

ramirez7 opened this issue Oct 2, 2023 · 2 comments

Comments

@ramirez7
Copy link

ramirez7 commented Oct 2, 2023

I saw this #513

I'm opening a new issue about the same thing.

YAML includes are inadequate for DRYing up even moderately-complex cabal config. Mostly due to the lack of recursive merge.

For instance, if I define a shared YAML file with default-extensions for my entire monorepo but a single package wants to add another default-extension just for itself, it clobbers the include. There's no good way around this using just YAML includes.

Now, if I could use cabal common stanzas, then YAML includes could help me:

  • I could define the common stanzas in shared YAML across my monorepo
  • My individual packages' package.yaml could include the common stanzas
  • Each package.yaml could then use cabal import accordingly.

I guess an alternative would be for hpack to add support for proper YAML recursive merge. But even if it had that, I don't see why hpack shouldn't support the cabal feature.

@ramirez7
Copy link
Author

ramirez7 commented Oct 2, 2023

(This seems like a pretty trivial feature to add, so if I find time, I'll just add it myself ✌️)

@MrQubo
Copy link

MrQubo commented Dec 16, 2023

That's so much needed. I've tried using hpack a few times, but always had to go back to using Cabal.

YAML's anchors are rarely enough. E.g. you can't use it with ghc-options, because this is a list and YAML doesn't support list concatenation. You can hack it like this (but that's very ugly):

when:
  - condition: true
    ghc-options: *ghc-options-warnings
  - condition: true
    ghc-options: *ghc-options-opt

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

2 participants