Repository navigation
RFC: Common stanzas - #4751
RFC: Common stanzas#4751
Conversation
|
@phadej, thanks for your PR! By analyzing the history of the files in this pull request, we identified @Ericson2314, @ezyang and @jutaro to be potential reviewers. |
|
Attempt on #2832 |
23Skidoo
left a comment
There was a problem hiding this comment.
Looks fine too, though we'll need a changelog note and some docs (same applies to the elif patch).
b1b0cb1 to
89492fd
Compare
89492fd to
048d86e
Compare
|
I have redone the PR. Ping @23Skidoo @hvr. There's internal note, I'll write a user guide section about common stanzas tomorrow if that behavior is ok. Difference to previous is that you cannot say includes should be first in stanza: |
|
@phadej This restriction seems reasonable to me, in fact I think that it improves readability. |
|
Two questions:
Easy to implement are:
Fourth variant is difficult, because with "Define everywhere + reference others (No/Yes):" we can write cycles: |
|
I'd say that requiring common stanzas to be defined before use is fine (provided that the error message is helpful). Regarding inheritance -- do you want to allow only or also ? |
|
You can |
|
To clarify the previous question, it can be posed also as Do we want to allow including stanzas from other common stanzas?. If yes, than we have to require define-before-use. |
IMO it can be useful, so I'm +1. One question: since IIRC list fields have monoid semantics, should there be a way to explicitly set a list field to will result in Should it be possible to do something like and have |
That's technically challenging because that alters Cabal's lexical syntax, which is very major change. |
What about e.g. ? However, I feel like we can postpone this, and add it at some later spec-version incrementally, when have gained more experienced/feedback with the basic support. (But we can surely spend some thought on how we could do it at some point in the future of course; but I think we are pretty sure we know how to do the "MVP" version now?) |
Yeah, it's totally fine to postpone this. I like the |
f02f838 to
9d6f4da
Compare
- common stanzas can be include other common stanzas - `import: name1, name2` to import multiple stanzas - Parse common stanzas in the same pass with other sections. - Common stanzas have to be defined before use. - Also negative tests - Terse documentation, let's improve it as questions are asked - Edit gen-extra-source-files to include golden files - Amend elif warning to mention cabal-version: 2.2 - In regression golden tests, include also warnings Note: ATM the common stanzas are completely handled inside parser, GenericPackageDescription doesn't know about them anymore. That can be changed, but the the flattening of GenericPackageDescription to PackageDescription may fail. I don't want to do that refactor now.
9d6f4da to
bfb1967
Compare
|
do we need a docs tweak? from reddit: "Unless I'm mistaken, it appears that import has to be the first thing in a stanza, but this isn't mentioned anywhere." |
|
I was just bitten by precisely the same thing @gbaz mentioned here. |
|
Doc change: #5610 |

Common stanzas
Please include the following checklist in your PR:
Please also shortly describe how you tested your change. Bonus points for added tests!