Closed tfausak closed 3 months ago
Rather than my janky Chunk
type, I think it makes sense to use the proper Condition ConfVar
for this.
It will require a bit of a rework to parse the arguments for if
(and elif
when cabal-version: >= 2.2
), but I think it's worth it.
Unfortunately the Condition
type doesn't have a CParen
constructor. That means it can't losslessly round-trip a conditional like this:
if !((x || y) && z)
The AST will be correct, but simply rendering it will give you this:
if !x || y && z
That could potentially be fixed by using a showsPrec
-style renderer. However sometimes users insert parentheses that aren't strictly necessary. I think Gild should retain those. So I'll probably need to write my own Condition
type, along with a parser and pretty printer.
The various ConfVar
types also have problems for me. Both OS
and Arch
have the concept of "strictness". The parser picks a strictness for me, so I can't make it permissive (unless it happens to already be that way). This is a problem because they have aliases. For example, AArch64
is the actual constructor, but it can allow an arm64
alias. I would prefer to keep whatever the user gave without translation. If that's not possible, I'd prefer to be as lax as possible, meaning allowing all aliases and converting them into their canonical form.
(Also they're case-insensitive, but that's not controlled by the strictness.)
There should be a space before
&&
.