As expected, the golden tests fail to run under Nix because the test
directory is not writable. And it's better to not write in my opinion,
let's not hack that and have a dry run output mode.
For now the output format is not structured, this is good enough for the
thests. It could be nice to do structured output in RCL format, but we
can do that later if needed.
I couldn't add a banner to the GitHub Actions yaml because the output
format is json which does not support comments. By making the banner
just a string that is up to the user to fill, everything becomes both
simpler and more general.
Vega is a data format, though one could say configuration format, for
declaratively defining data visualizations. It can be generated from
Python using Altair, but how about generating it with RCL?
I don't know if this is a good idea, but it is at least possible.
And it's already way more convenient to write than writing json in
the online editor, because in RCL you don't have to quote the keys.
At first I thought, “but a single-element collection should always fit,
right?” And sure it fits, but then I reformatted a larger experimental
config I have, including some GitHub Actions, and it turns out that
sometimes I prefer even single-element litst to be tall. Black is right
about this. I should be less opinionated, leave it to the user.
This gives users a bit more control over whether things get formatted
wide or tall. This matters in practice, as Black learned the hard way,
and I did as well in the GitHub Actions example.
In the past I did not autoformat them because I was not happy with the
output yet, but now the formatter is good enough that I'm willing to
take this. There are still a few cases where I'm like ... meh, but that
requires human judgement that I think a formatter can never get right,
so I'm willing to stop arguing about this to get a formatter.
Possibly in the future I can add the magic trailing comma like Black has
in Python, to force collections to be tall. That could still be nice.
We can do that in a follow-up.
I realized I'm often complaining about tools for not having good
documentation. I tried to get started with D for the Advent of Code
for example, and although it has a reference, I couldn't find good
introductory material. RCL doesn't even have an introduction, so let's
fix that.
I am still ambivalent about this. On the one hand I have a strong sense
that "key = value;" is a statement that needs a terminator. On the other
hand, it makes things more uniform to have only a single separator.
I think I just need to get used to the comma, and then I will not mind
so much. But let's see.
We have to look at the syntactic construct, we cannot look at the
runtime value. Otherwise, because an empty collection is a dict, the
following would be a dict:
{for x in xs: x}
Even though we can tell that it's a set, because it contains a scalar
value in the comprehension, not a key-value pair.
I need some kind of group by for this, and for that I need what in
Haskell is called unionWith. I could add that as a builtin on maps,
then I need to implement lambdas to make progress.
But now there is a dilemma. All of that is much nicer syntax-wise and
typecheck-wise if there were freestanding functions instead of methods.
And when you define helpers yourself, they are going to be free-standing
anyway. So maybe it's better to make them free-standing from the start?
But anyway that's for later.
This is a major complication, but I do want to be able to build an
autoformatter, and then I will need one, so let's do it from the start,
I think it will be less work in the end.
There is the part that is now working, for which I wrote the AST by
hand, and for which I can write a parser now.
And then there is the part which is still vaporware, my scratchpad to
write down ideas, so let's split that out too.