-
Notifications
You must be signed in to change notification settings - Fork 697
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
Semantics of index-state in cabal.project #8568
Comments
Just checking @andreabedini, I think we found that this also doesn't work?
In terms of expected semantics, my naive expectation is that cabal does something like "overriding union" when it sees a subsequent stanza of the same kind, i.e. it unions as much as possible, and where there's a conflict it takes the later one. e.g. if you have two So I think the surprise is that we would expect cabal to be able to do some unioning here but in fact it just overrides the whole value. Especially in the case where there are two index-states for different repositories (the one with the "unqualified" index-state and the "qualified" one is a bit trickier). |
Rough diagnosis: the
If I understand correctly, that will make cabal do the right thing when parsing. I'm giving it a shot. |
Yes,
would use HEAD as index-state for hackage. |
WIP here: https://github.com/michaelpj/cabal/tree/mpj/merge-index-states Need to figure out how to write a test. |
It's not exactly clear to me that the proposed semantics is any better than the current one, and the switch will probably break someone's code. It'd be interesting to try to solicit opinions on this on Discourse/Reddit/Cafe. |
FWIW, the proposed semantics makes more sense to me than the currently-implemented one. I don't expect actual cider to be broken by this proposal. I support this change, which actually is a fix. |
The current behavior is so that if there is If you add a TL;DR IIRC I did what was simplest at the time. I doubt it will break much code as multiple repositories and index-states using them are not that common combination. FWIW: |
It took me a while to see the problem, so let me see if I can say it right. The change I propose is basically just:
So the first
So indeed fixing this properly would need the first field to be |
No, you understood me wrong. Nothing have to change about The ProjectConfigShared have to be changed to data ProjectConfigShared =
...
projectConfigIndexState :: PartialIndexState,
... where the naive implementation could be newtype PartialIndexState = PartialIndexState (TotalIndexState -> TotalIndexState)
toTotalIndexState :: PartialIndexState -> TotalIndexState
toTotalIndexState (PartialIndexState f) = f headTotalIndexState
fromTotalIndexState :: TotalIndexState -> PartialIndexState
fromTotalIndexState tis = PartialIndexState (\_ -> tis) however that representation won't work as you cannot pretty print it. EDIT: I don't remember how TotalIndexState is represented now, maybe |
@andreabedini: do you have a good enough workaround? @michaelpj: is there a way to cheaply salvage your work and improve the situation, before you completely context switch? |
@Mikolaj yes, we have a workaround. Thanks for asking. |
I got stuck thinking about what @phadej said. I think the fundamental change is not that hard, it's just representing it in a way that matches the way the cabal devs want to think about it.
I think my previously linked tree provides some value if someone else wants to pick this up, I am planning to come back to this when I get some free cycles but I'm not sure when that will be, especially since we have a workaround. |
I think we'll need a EDIT: also |
I am ok with the current state now that is clear this is the intended behaviour. @michaelpj, can you open a separate PR? |
You mean a separate issue? I'm unclear that this is desirable behaviour but I also think it's not a huge deal, if we have a way to deal with it. |
Nevermind, I was under the impression you where working on some changes. |
The second index-state stanza completely ovverides the first, resetting hackage index state to HEAD. See haskell/cabal#8568
The second index-state stanza completely ovverides the first, resetting hackage index state to HEAD. See haskell/cabal#8568
The second index-state stanza completely ovverides the first, resetting hackage index state to HEAD. See haskell/cabal#8568
The second index-state stanza completely ovverides the first, resetting hackage index state to HEAD. See haskell/cabal#8568
The second index-state stanza completely ovverides the first, resetting hackage index state to HEAD. See haskell/cabal#8568
The second index-state stanza completely ovverides the first, resetting hackage index state to HEAD. See haskell/cabal#8568
The second index-state stanza completely ovverides the first, resetting hackage index state to HEAD. See haskell/cabal#8568
The second index-state stanza completely ovverides the first, resetting hackage index state to HEAD. See haskell/cabal#8568
The second index-state stanza completely ovverides the first, resetting hackage index state to HEAD. See haskell/cabal#8568
* Fix index-state syntax The second index-state stanza completely ovverides the first, resetting hackage index state to HEAD. See haskell/cabal#8568 * Update cabal.project
* Fix index-state syntax The second index-state stanza completely ovverides the first, resetting hackage index state to HEAD. See haskell/cabal#8568 * Update cabal.project
4288: Fix index-state syntax r=amesgen a=andreabedini # Description The second index-state stanza completely ovverides the first, resetting hackage index state to HEAD. See haskell/cabal#8568 Co-authored-by: Andrea Bedini <andrea.bedini@tweag.io>
4288: Fix index-state syntax r=amesgen a=andreabedini # Description The second index-state stanza completely ovverides the first, resetting hackage index state to HEAD. See haskell/cabal#8568 Co-authored-by: Andrea Bedini <andrea.bedini@tweag.io>
4288: Fix index-state syntax r=amesgen a=andreabedini # Description The second index-state stanza completely ovverides the first, resetting hackage index state to HEAD. See haskell/cabal#8568 Co-authored-by: Andrea Bedini <andrea.bedini@tweag.io>
The second index-state stanza completely ovverides the first, resetting hackage index state to HEAD. See haskell/cabal#8568
3700: Fix index-state syntax r=Anviking a=andreabedini The second index-state stanza completely ovverides the first, resetting hackage index state to HEAD. See haskell/cabal#8568 <!-- Detail in a few bullet points the work accomplished in this PR. Before you submit, don't forget to: * Make sure the GitHub PR fields are correct: ✓ Set a good Title for your PR. ✓ Assign yourself to the PR. ✓ Assign one or more reviewer(s). ✓ Link to a Jira issue, and/or other GitHub issues or PRs. ✓ In the PR description delete any empty sections and all text commented in <!--, so that this text does not appear in merge commit messages. * Don't waste reviewers' time: ✓ If it's a draft, select the Create Draft PR option. ✓ Self-review your changes to make sure nothing unexpected slipped through. * Try to make your intent clear: ✓ Write a good Description that explains what this PR is meant to do. ✓ Jira will detect and link to this PR once created, but you can also link this PR in the description of the corresponding Jira ticket. ✓ Highlight what Testing you have done. ✓ Acknowledge any changes required to the Documentation. --> - [ ] I have ... ### Comments <!-- Additional comments, links, or screenshots to attach, if any. --> ### Issue Number <!-- Reference the Jira/GitHub issue that this PR relates to, and which requirements it tackles. Note: Jira issues of the form ADP- will be auto-linked. --> Co-authored-by: Andrea Bedini <andrea.bedini@tweag.io>
…ini The second index-state stanza completely ovverides the first, resetting hackage index state to HEAD. See haskell/cabal#8568 <!-- Detail in a few bullet points the work accomplished in this PR. Before you submit, don't forget to: CODE-OF-CONDUCT.md LICENSE README.md bors.toml cabal.project default.nix docker-compose.yml docs flake.lock flake.nix floskell.json hie-direnv.yaml lib nix prototypes reports scripts shell.nix specifications test touch.me.CI weeder.dhall Make sure the GitHub PR fields are correct: ✓ Set a good Title for your PR. ✓ Assign yourself to the PR. ✓ Assign one or more reviewer(s). ✓ Link to a Jira issue, and/or other GitHub issues or PRs. ✓ In the PR description delete any empty sections and all text commented in <!--, so that this text does not appear in merge commit messages. CODE-OF-CONDUCT.md LICENSE README.md bors.toml cabal.project default.nix docker-compose.yml docs flake.lock flake.nix floskell.json hie-direnv.yaml lib nix prototypes reports scripts shell.nix specifications test touch.me.CI weeder.dhall Don't waste reviewers' time: ✓ If it's a draft, select the Create Draft PR option. ✓ Self-review your changes to make sure nothing unexpected slipped through. CODE-OF-CONDUCT.md LICENSE README.md bors.toml cabal.project default.nix docker-compose.yml docs flake.lock flake.nix floskell.json hie-direnv.yaml lib nix prototypes reports scripts shell.nix specifications test touch.me.CI weeder.dhall Try to make your intent clear: ✓ Write a good Description that explains what this PR is meant to do. ✓ Jira will detect and link to this PR once created, but you can also link this PR in the description of the corresponding Jira ticket. ✓ Highlight what Testing you have done. ✓ Acknowledge any changes required to the Documentation. --> - [ ] I have ... ### Comments <!-- Additional comments, links, or screenshots to attach, if any. --> ### Issue Number <!-- Reference the Jira/GitHub issue that this PR relates to, and which requirements it tackles. Note: Jira issues of the form ADP- will be auto-linked. --> Co-authored-by: Andrea Bedini <andrea.bedini@tweag.io> Source commit: 6dca83f
The second index-state stanza completely ovverides the first, resetting hackage index state to HEAD. See haskell/cabal#8568
An example of where the current behaviour would be undesirable. Suppose we have nightly GHC distributions. Users using a particular nightly may also want to use a particular
However, the natural way of using this won't work:
Oops! This clobbers the |
The second index-state stanza completely ovverides the first, resetting hackage index state to HEAD. See haskell/cabal#8568
imho the right thing here is a monoid with the following semantics -- we start with a fixed total indexed state for all repos. then, in order, every subsequent partial element just overrides the fixed total state for that one repo, and hitting a new total timestamp resets everything that came before. I'm pretty sure this obeys the monoid laws -- we just need to specify that an partial override with no initial corresponding total element is interpreted as having one anyway, semantically. i know i wrote it a bit confusingly, but there's a real monoid here, just not a very standard one. |
I think the use case that @michaelpj presents in #8568 (comment) is compelling. Implementation-wise I think we are stuck on #6101 (striclty speaking we are not, but I won't spend time on the legacy parser :P) |
@michaelpj use case is compelling, but E.g.
then people are stuck, if they e.g. want different So if you make a breaking but subtle change to I agree that TL;DR, once you "fix" Which leads me to another point: |
Okay, let me make a different proposal. If I understand correctly, part of the objection is that But... isn't
The situation today is as if we declared this with Moreover, we even have an element for setting options relating to repositories: the
This I think has the best of both worlds: individual option settings are overriding, but we have separate option settings for different scopes, which represents what we want to say nicely. |
I wouldn't write
I'd also like to write
or
This is matter of taste (but @michaelpj sure, today I write
and it would be fine to write
(and have the semantics of repository stanzas you mention) and the latter is actually good, as probably something like
or
can be written later to override the choice. I.e. but I cannot reset
I b0rk by project, It's good to improve
TL;DR make |
if monoidal semantics are added, there probably need to be a way to reset to "global" per-repository index-states
would result into I don't have a motivation for this, other than countering the @michaelpj if I need to repeat In repository stanza syntax (which I don't like)
one would need a way to reset This reminds me that package aeson
flags: +foo there is no AFAIK a way to reset it to the package (versions') default. (EDIT: nor can flags specified in be overriden, |
This is also something that we want to fix. And in general I agree there should be a full revamp to make virtually anything in cabal.project overridable. cf. the discussion here #9510 The asks in this ticket and that that PR is trying to resolve are longstanding goals which we have intended to implement ever since conditional and imports were introduced to project files. Implementation-wise none of these changes require changing the parser. We already accumulate all fields with some form of monoidal semantics -- we just need to pick appropriate monoids compared to the ones we use now. Finally, I disagree on blocking these changes on making cabal.project versioned. We should be careful we don't alter existing common, meaningful syntax. However, there's been a longstanding view that foo.cabal files should be versioned because that syntax is part of the specification of a package, while cabal.project files are not that -- they're auxiliary tools, and since cabal-install is backwards compat with prior ghc versions, its ok, if not awesome, to have users update them to keep pace with new versions of cabal-install they are developing with. I'm open to someone implementing new cabal project versioning in the future. But there's no reason to prevent us from continuing to improve things now. tl;dr: oleg's comments are useful but some version of addressing this issue, constraints, and other overrides in cabal.project files is absolutely in keeping with the current direction of travel of cabal.project files. |
With respec to overriding constraints, see my comment here. IMHO the real use case is to choose a package version and solve for the rest. "overriding constraints" is one possible technical solution but to be honest I am not particularly fan of, due to its unclear semantic. |
The second index-state stanza completely ovverides the first, resetting hackage index state to HEAD. See haskell/cabal#8568
At IOG we have started using a custom hackage repositories, which we informally call CHaP.
To add the custom repository to a project we have been doing
We thought the first
index-state
would apply to all active repositories, and the second one only to the specified repository. (For context: we did this because we were working around a limination with another tool which we use to parsecabal.project
).But we were wrong! After a while it became clear that the second index-state completely overrides the first (as the first was never there).
Indeed, the correct way to express two index-states would be
index-state
stanza (for different repos)Thanks!
Ping @michaelpj @angerman
The text was updated successfully, but these errors were encountered: