-
Notifications
You must be signed in to change notification settings - Fork 696
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
Extend .cabal
format with "common" definition stanzas
#2832
Comments
As I can see from proposal, Does this imply that they are handled by parser, i.e. not visible in From tooling point of view, I'd like to see them in Shortly, which: -- current
condExecutables :: [(String, CondTree ConfVar [Dependency] Executable)]
-- anywhere, each block consists of includefields and "the thing"
condExecutables :: [(String, CondTree ConfVar [Dependency] [Either IncludeField Executable])]
-- only on top
condExecutables :: [(String, CondTree ConfVar [Dependency] ([IncludeField], Executable))] |
Another comment, |
@phadej as to the file-including, there's two ideas on the table, either use non-overloaded Then |
Ok, I agree, let's keep |
Question: should stanzas be declared before used? If yes, then recursive acyclic stanzas are easy to implement (as stanzas overall) I have no preference on this. |
I'd say yes, it makes sense to nudge users to put |
Motivated by possible in-parser implementation. There are two ways to parse common stanza: parse them beforehand or not.
|
Another comment:
says that
and it will be kind-of-correct (have to warn that Alternatively we could have
|
I don't think this needs to be the case. The common stanzas can be "typed" so that both Cabal (and the reader!) knows where they can go. For example,
I imagine the common build-info stanza would be the most popular by far. Even if we only implemented common build-info stanzas, I think that would be a big improvement. |
@ttuegel, yes, that's another option. And I do actually like it, except for section names; OTOH I cannot think any better ones. |
Yes, I should have added, those section names are awful and shouldn't be considered for a real implementation! A serious suggestion: we could add an ellipsis after the name to indicate a common section, i.e. |
@ttuegel While it's concise, I'm not sure I like using trailing punctuation to denote a difference (and also I don't think that the meaning of However, I'd prefer the more verbose/explicit syntax which doesn't introduce a new style of keywords by via non-alpha-nums. And I assume Fwiw, other bikeshed names instead of |
I was only thinking about named sections... I think that's good, but I would prefer to call it something different. If it has the same syntax as a named section, I think it's too easy to accidentally leave off the name. This way, the user gets a parse error if they leave off the name accidentally. For the global sections, we could use |
Embrace hpack to cover this? Mostly a bystander, but just noting an alternative (which I am guessing everybody has already considered) |
@kanishka-azimi Yes, I briefly considered the concept of |
Okay, makes sense. I ran across your yaml note last night, agree yaml, though somewhat light on noise, has ugly corners in it's definition. I created an issue in hpack to consider json, as a compromise between standard format but more limited complexity, at the cost of a little more syntax noise. I will close that issue as it probably still is more bloated than a cabal specific syntax. The thing I like most about hpack is that people can contribute to it in relative isolation. It's intimidating seeing a repo with 800 issues, having to think about reverse compatibility, and it's a slight detour to learn a custom parser instead of a typical Json parser. Hpack will encounter the reverse compatibility issue with age... If you can keep that spirit alive, either with a second sublibrary for the cabal parser or just a well demarcated set of modules, that might increase the rate of community contributions to the revamped cabal syntax. Look forward to seeing the future of what you all come up with. |
Just while we're speculating, I wonder if people have though the necomer in the "config language" space, Dhall. Seems to have some very nice properties. |
@BardurArantsson Dhall is definitely interesting in its own right (and I'm waiting for an occasion to make use of it), but it appears to me that by being actually a programming language (rather than a declarative package specification with enough structure to support automatic refactoring) it's also way too powerful for what we'd want for |
(I'll stop with the semi-OT after this.) I keep hearing about automatic refactoring (and perhaps GUI tools?), but how realistic is it to expect any such thing for Cabal? I honestly don't think it's even close to realistic enough to worry about as a goal. Plus we're talking files of (at most) a 100-200 or so lines. Who actually needs automated refactoring for that? (Especially with something like Dhall, you could probably cut down on the size drastically.) Heck, in JVM-land even Maven had the original goal of having pom.xml files mostly being edited with a GUI tool, but as it turned nobody actually wanted that -- so almost everybody just edits the XML directly. |
@BardurArantsson For one, haskell-mode or more generally things like haskell-ide-engine would greatly benefit from the ability to understand the structure of But more importantly, I'm working on tools to assist Hackage curation by Trustees & maintainers, and one super boring, time-consuming and error-prone task is to step in and modify version bounds by hand. But more importantly, we want to make the recommended PVP-workflow more convenient, and for that imagine if we had this process automated to the point where you get presented with all information (changelog, API deltas, test/build-reports, etc) involving a new major version of your dependency, and you just have to click a button on Hackage to confirm that bumping that specific upper version bound is safe (rather than the alternative of flying blind by leaving off upper bounds altogether). |
@hvr Ah, true, I hadn't considered the Hackage version bound thing. |
Just a note re |
`cabal-install.cabal` would greatly benefit from common stanzas (haskell#2832) as it would help reduce the redundancy singnificantly.
this should hopefully silence all 4 combinations of flag(lib) and flag(monolithic). `cabal-install.cabal` would greatly benefit from common stanzas (haskell#2832) as it would help reduce the redundancy singnificantly.
this should hopefully silence all 4 combinations of flag(lib) and flag(monolithic). `cabal-install.cabal` would greatly benefit from common stanzas (haskell#2832) as it would help reduce the redundancy singnificantly.
Closing as fixed. |
( this is a project task description for the upcoming https://github.com/haskell/cabal/wiki/Hackathon2015 )
One complaint about the
.cabal
format is that there's avoidable duplication when multiple stanzas requiring to repeat some shared properties are involved (most notablybuild-depends
)Here's an example how common stanzas could be used:
In the example above a single common section named
cdef1
is defined, which is included by all 3 real stanzas.include cdef
acts as if the respective common stanza's body was inserted in place ofinclude cdef
.Possible extensions
all
,library
,test-suites
, andbenchmark
to declare common stanzas that are implicitlyinclude
d by the respective named real stanza. In the example above we could have usedcommon all
instead ofcommon cdef1
and allinclude cdef1
simply removed.include
other common stanzas./cc @dcoutts
@dcoutts suggests to support both,
Moreover, we'd want this mechanism not only for
.cabal
files but also for cabal's config files. For non-.cabal
files we want to reuse the infrastructure for file-backed include files (include-file ./some-ast-frament.inc
).refinement: common stanzas ought to be typed so we can catch mistakes early on during parsing already, see #2832 (comment)
The text was updated successfully, but these errors were encountered: