You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
As discussed in #7548 (comment) , some people find a dependency on the full Cabal library somewhat heavyweight for just doing cabal file parsing without actually executing any builds.
In general, I think splitting off the basic file parsing and syntax tree stuff of the lib into Cabal-syntax or the like would be a fine idea, and probably help with code organization to boot.
Maybe this could be a next step after the exactprint work, and it might also help encourage ides to integrate with the cabal library.
Ideally I think this (along with exact-print) would help tools be more comfortable using the already built utilities for cabal files instead of rolling their own (or punting).
Reacted by Alistair Burrowes, Javier Neira , Daniel Gröber (dxld), ptkato and John Ericson
Note that hvr also has an experimental cabal-parsers library (unreleased on hackage) that glues together the parsing code from various cabal versions so it can run them explicitly to check: https://github.com/haskell-hvr/cabal-parsers/ -- Pulling out Cabal's parser stuff into its own lib could considerably simplify such a package (but more generally pinning down a properly versioned cabal bnf etc could obviate the need for it).
I'm 👎 on moving cabal-install-parsers stuff into Cabal-syntax. The cabal-install files (cabal.config, cabal.project) are cabal-install specific, e.g. stack will do completely nothing with them. Also these files change more often. Cabal-syntax library is big on its own, no need to artificially enlarge its API surface.
cabal-parsers idea is to be bug compatible. It's a pragmatic way to check that old cabal-installs can parse stuff uploaded on Hackage, removing the burden of being bug-compatible from the Cabal(-syntax) library itself.
I'm pretty sure that Cabal-syntax dealing only with .cabal files could be even pulled out of this repository and developed and maintained by different (can be obviously overlapping) folks in their own pace. That's another argument to not couple it to cabal-install.
The only change needed for new GHC releases in format part of the lib, IIRC, is adding extensions & languages. Woiuld be nice to refactor the library to make those changes non-breaking changes PVP-wise. (I doubt anyone does exhaustive pattern match on extensions, yet there is only three languages, so someone might do that). TL;DR Language and Extension type could be made opaque or internal, so adding new constructors won't force major version bump.
I took a crack at this to get familiar with the code base. In #7620 I've mostly just done the mechanical part of the separation, without any refactoring/renaming of anything. Cabal spit pretty naturally into two pieces, with [Generic]PackageDescription on one side and the Distribution.Simple stuff on the other.
If you think this is along the right lines, I'm open to refactor as much as you'd like. Otherwise I'm also fine to just scrap it :)
Reacted by Francesco Gazzetta, Javier Neira and Mikolaj Konarski
I mean moved back out of Cabal-syntax. I think a good heuristic is anything that mainly exists to provide some data types shouldn't be doing much IO, so looking through the IO usage is a good way to double check the work.
As far as I can tell the initial split was done not super fine-grained ---- which makes sense! Keeps the diff less unruly. We also did fairly simple splits when breaking up https://github.com/simonmar/happy for the same reason. But once the initial split is done, then a second pass can polish things up. I think going through the IO is a good way to do that second pass.
I disagree. We wanted the split to be along module lines. Anything more "fine grained" would be far more disruptive.
Further, there is nothing in the "idea" of cabal-syntax that says "no IO." It is a library for working with cabal file syntax. That can include functions that e.g. read in files or write them out.
Also, I notice that as the split is now merged we should close this ticket.
Activity
gbaz commentedon Aug 19, 2021
Note that hvr also has an experimental cabal-parsers library (unreleased on hackage) that glues together the parsing code from various cabal versions so it can run them explicitly to check: https://github.com/haskell-hvr/cabal-parsers/ -- Pulling out Cabal's parser stuff into its own lib could considerably simplify such a package (but more generally pinning down a properly versioned cabal bnf etc could obviate the need for it).
phadej commentedon Aug 19, 2021
I'm 👎 on moving
cabal-install-parsersstuff intoCabal-syntax. Thecabal-installfiles (cabal.config,cabal.project) arecabal-installspecific, e.g.stackwill do completely nothing with them. Also these files change more often.Cabal-syntaxlibrary is big on its own, no need to artificially enlarge its API surface.cabal-parsersidea is to be bug compatible. It's a pragmatic way to check that oldcabal-installs can parse stuff uploaded on Hackage, removing the burden of being bug-compatible from theCabal(-syntax)library itself.phadej commentedon Aug 19, 2021
I'm pretty sure that
Cabal-syntaxdealing only with.cabalfiles could be even pulled out of this repository and developed and maintained by different (can be obviously overlapping) folks in their own pace. That's another argument to not couple it tocabal-install.The only change needed for new GHC releases in format part of the lib, IIRC, is adding extensions & languages. Woiuld be nice to refactor the library to make those changes non-breaking changes PVP-wise. (I doubt anyone does exhaustive pattern match on extensions, yet there is only three languages, so someone might do that). TL;DR
LanguageandExtensiontype could be made opaque or internal, so adding new constructors won't force major version bump.gbaz commentedon Aug 19, 2021
Ok, I'm fine with cabal-install-parsers not getting moved as well -- I did say it was a more wild idea :-)
The proposal on
LanguageandExtensionbeing opaque makes a lot of sense as well.patrickdoc commentedon Sep 4, 2021
I took a crack at this to get familiar with the code base. In #7620 I've mostly just done the mechanical part of the separation, without any refactoring/renaming of anything.
Cabalspit pretty naturally into two pieces, with[Generic]PackageDescriptionon one side and theDistribution.Simplestuff on the other.If you think this is along the right lines, I'm open to refactor as much as you'd like. Otherwise I'm also fine to just scrap it :)
phadej commentedon Sep 4, 2021
@patrickdoc That is great! I'll take a look.
Mikolaj commentedon Jan 26, 2022
#7620 has been merged. What next?
Ericson2314 commentedon Feb 15, 2022
git grep -w IO Cabal-syntax/is a pretty quick-and-dirty way to find bits and pieces that should probably be moved back to Cabal.Mikolaj commentedon Feb 15, 2022
@Ericson2314: you mean, re-exported from Cabal?
Ericson2314 commentedon Feb 16, 2022
I mean moved back out of
Cabal-syntax. I think a good heuristic is anything that mainly exists to provide some data types shouldn't be doing much IO, so looking through the IO usage is a good way to double check the work.As far as I can tell the initial split was done not super fine-grained ---- which makes sense! Keeps the diff less unruly. We also did fairly simple splits when breaking up https://github.com/simonmar/happy for the same reason. But once the initial split is done, then a second pass can polish things up. I think going through the IO is a good way to do that second pass.
gbaz commentedon Feb 16, 2022
I disagree. We wanted the split to be along module lines. Anything more "fine grained" would be far more disruptive.
Further, there is nothing in the "idea" of cabal-syntax that says "no IO." It is a library for working with cabal file syntax. That can include functions that e.g. read in files or write them out.
Also, I notice that as the split is now merged we should close this ticket.